
//============================================================================================
/**
 * @file	phclink.c
 * @brief	ＰＨＣ−ＤＳ接続画面メイン
 * @author	Akito Mori
 * @date	09.01.29
 */
//============================================================================================
#include "common.h"
#include "gflib/touchpanel.h"
#include "system/gamedata.h"
#include "system/procsys.h"
#include "system/main.h"
#include "system/fontproc.h"
#include "system/window.h"
#include "system/pmfprint.h"
#include "system/snd_tool.h"
#include "system/arc_tool.h"
#include "system/arc_util.h"
#include "system/clact_tool.h"
#include "system/clact_util.h"
#include "system/msgdata.h"
#include "system/wordset.h"
#include "system/mystatus.h"
#include "system/wipe.h"
#include "system/gra_tool.h"
#include "system/pm_rtc.h"
#include "gflib/strbuf_family.h"
#include "savedata/config.h"
#include "savedata/tr_house.h"
#include "savedata/zukanwork.h"
#include "itemtool/item.h"
#include "itemtool/myitem.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_phc_com.h"
#include "battle/battle_common.h"
#include "poketool/pokeicon.h"
#include "tr_house/tr_house_phc.h"

#include "application/phclink.h"
#include "phclink_obj_def.h"
#include "phclink_bmp_def.h"
#include "phclink_local.h"
#include "phclink_obj.h"
#include "phclink_bmp.h"
#include "phc_ds.naix"
#include "phcgra.naix"
#include "phc_course.h"
#include "course/coursedata.dat"
#include "pmdp_327_buchi.h"

//============================================================================================
//	定数定義
//============================================================================================



//============================================================================================
//	プロトタイプ宣言
//============================================================================================
static void SaveDataGet( PHCLINK_WORK * wk );
static void VBlankFunc( void * work );
static void VramBankSet(void);
static void BgInit( GF_BGL_INI * bgl );
static void BgExit( GF_BGL_INI * bgl );
static void BgGraphicSet( PHCLINK_WORK * wk );
static void MsgManCreate( PHCLINK_WORK * wk );
static  u32 TouchButtonControl( PHCLINK_WORK * wk, int mode );
static void MsgManRelease( PHCLINK_WORK *wk );
static  int MainSeqFunc( PHCLINK_WORK *wk );
static void set_image( PHCLINK_WORK *wk, PHCImageData *myImageData );
static void set_course( PHCCourseData *pCourse, PHCLINK_WORK *wk );

static int get_pixel_sub( u8 *data, int w, int x, int y );
static int bmp2phc( u8 *bmp, int in_w, int in_h, u8 *phc, int x, int y, int w, int h );
static void  _set_bmpwin_buf( GF_BGL_BMPWIN *bmpwin, PHCLINK_WORK *wk, const PHC_COURSE_DATA *course, u8 select[] );
static void TypeCheckEncount( const u8 advantage[], POKEMON_PASO_PARAM *ppp, u16 walkStep[] );
static void _set_bmpwin_myname( GF_BGL_BMPWIN *bmpwin, PHCLINK_WORK *wk );
static int _get_phcicon_index_ppp( POKEMON_PASO_PARAM *ppp );
static int _get_phcicon_index_monsno( int mons );
static void _tr_house_data_make( PHCLINK_WORK *wk );
static void MakePattiiruBuchi( u8* buf, const u8 *mask, u32 rnd );


PROC_RESULT PhcLinkProc_Init( PROC * proc, int * seq );
PROC_RESULT PhcLinkProc_Main( PROC * proc, int * seq );
PROC_RESULT PhcLinkProc_End( PROC * proc, int * seq );




//============================================================================================
//	グローバル変数
//============================================================================================

///< プロセス定義データ
const PROC_DATA PhcLinkProcData = {
	PhcLinkProc_Init,
	PhcLinkProc_Main,
	PhcLinkProc_End,
	NO_OVERLAY_ID,
};



///< 下画面の決定ボタンのタッチ座標テーブル
static const RECT_HIT_TBL EnterButtonRect[] =
{
	{ 168, 191, 128, 183,},
	{ 56, 103, 104, 151  },
	{ RECT_HIT_END, 0, 0, 0 },
};




//============================================================================================
//	プロセス関数
//============================================================================================

///< PHC画面での各々のプロセス（初期化・メイン・終了）処理記述テーブル
static int (*SubSeqFuncTbl[][3])( PHCLINK_WORK *wk ) = {
	{ PhcLink_SeqStart_Init, 		PhcLink_SeqStart_Main, 		PhcLink_SeqStart_End       },	// MAINSEQ_START=0,
	{ PhcLink_SeqError_Init, 		PhcLink_SeqError_Main, 		PhcLink_SeqError_End       },	// MAINSEQ_ERROR,
	{ PhcLink_SeqInitialize_Init, 	PhcLink_SeqInitialize_Main, PhcLink_SeqInitialize_End  },	// MAINSEQ_INITIALIZE,
	{ PhcLink_SeqSendRecv_Init, 	PhcLink_SeqSendRecv_Main, 	PhcLink_SeqSendRecv_End    },	// MAINSEQ_SENDRECV,
	{ PhcLink_SeqExtradition_Init, 	PhcLink_SeqExtradition_Main,PhcLink_SeqExtradition_End },	// MAINSEQ_EXTRADITION
	{ PhcLink_SeqSendDemo_Init, 	PhcLink_SeqSendDemo_Main, 	PhcLink_SeqSendDemo_End    },	// MAINSEQ_SEND_DEMO,
	{ PhcLink_SeqRecvDemo_Init, 	PhcLink_SeqRecvDemo_Main, 	PhcLink_SeqRecvDemo_End    },	// MAINSEQ_RECV_DEMO,
	{ PhcLink_SeqPokeSelect_Init, 	PhcLink_SeqPokeSelect_Main,	PhcLink_SeqPokeSelect_End  },	// MAINSEQ_POKE_SELECT
	{ PhcLink_SeqDiary_Init, 		PhcLink_SeqDiary_Main,		PhcLink_SeqDiary_End       },	// MAINSEQ_DIARY,
	{ PhcLink_SeqMapSelect_Init, 	PhcLink_SeqMapSelect_Main,	PhcLink_SeqMapSelect_End   },	// MAINSEQ_MAP_SELECT,
	{ PhcLink_SeqBenefit_Init, 		PhcLink_SeqBenefit_Main,	PhcLink_SeqBenefit_End     },	// MAINSEQ_BENEFIT
};


//--------------------------------------------------------------------------------------------
/**
 * @brief	プロセス関数：初期化
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT PhcLinkProc_Init( PROC * proc, int * seq )
{
	PHCLINK_WORK * wk;

	sys_VBlankFuncChange( NULL, NULL );	// VBlankセット
	sys_HBlankIntrStop();				// HBlank停止

	GF_Disp_GX_VisibleControlInit();
	GF_Disp_GXS_VisibleControlInit();
	GX_SetVisiblePlane( 0 );
	GXS_SetVisiblePlane( 0 );

	G2_BlendNone();
	G2S_BlendNone();

	// リセット禁止
	sys_SoftResetNG( SOFTRESET_TYPE_PHC );

	// ヒープ作成
	sys_CreateHeap( HEAPID_BASE_APP, HEAPID_PHC_LINK, 0x70000 );

	wk = PROC_AllocWork( proc, sizeof(PHCLINK_WORK), HEAPID_PHC_LINK );
	memset( wk, 0, sizeof(PHCLINK_WORK) );
//	wk->savedata = PROC_GetParentWork( proc );
	wk->savedata = ((MAINWORK *)PROC_GetParentWork(proc))->savedata;

	// セーブデータ読み込み

	// セーブデータから基本情報取得
	SaveDataGet( wk );

	sys_KeyRepeatSpeedSet( 3, 8 );

	InitTPSystem();					// タッチパネルシステム初期化
	InitTPNoBuff(4);

	// BG設定、OAM設定
	PhcLink_ResourceInit( wk );


//	Snd_DataSetByScene( SND_SCENE_SUB_BAG, 0, 0 );	// サウンドデータロード(バッグ)(BGM引継ぎ)

	// 会話ウインドウスキップ設定
	MsgPrintSkipFlagSet( MSG_SKIP_ON );



	return PROC_RES_FINISH;
}

//------------------------------------------------------------------
/**
 * @brief   BG設定、OAM設定（復帰時も使用)
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
void PhcLink_ResourceInit( PHCLINK_WORK *wk )
{

	// BGL確保
	wk->bgl  = GF_BGL_BglIniAlloc( HEAPID_PHC_LINK );

	// タッチフォントロード
	FontProc_LoadFont( FONT_TOUCH, HEAPID_PHC_LINK );

	MsgManCreate( wk );				// メッセージマネージャー作成

	VramBankSet();					// VRAM設定
	BgInit( wk->bgl );				// BG設定
	BgGraphicSet( wk );				// BGグラフィックセット

	PhcLinkBmp_Init( wk, PL_BMP_PAGE_A );					// BMPウィンドウ設定
	PhcLinkBmp_Init( wk, PL_BMP_PAGE_B );					// BMPウィンドウ設定

	// セルアクター初期化
	PhcLinkObj_Init( wk );

	// カーソル初期化非表示
	PhcLinkObj_CursorInit(wk);

	// メッセージをタッチパネルでも送れるように設定
	MsgPrintTouchPanelFlagSet( MSG_TP_ON );

	PhcLinkBmp_MenuStrGet( wk );			// メニュー項目取得

//	PhcLinkBmp_CancelPrint( wk );			// 「やめる」表示

	// ページ設定
//	PhcLinkObj_ItemIconSet( wk, &wk->dat->p_data[wk->dat->p_now], _get_page_button_num(wk), 1 );


	sys_VBlankFuncChange( VBlankFunc, wk );		// VBlankセット


	//メイン画面を下で表示
	GX_SetDispSelect( GX_DISP_SELECT_SUB_MAIN );
	GF_BGL_VisibleSet( GF_BGL_FRAME0_S, VISIBLE_ON );

}

//==============================================================================
/**
 * @brief   PHC接続画面用リソース周り解放
 *
 * @param   wk		 PHC画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_ResourceExit( PHCLINK_WORK *wk )
{
	// セルアクター解放
	PhcLinkObj_ClactFree( wk );

	OS_Printf("bmpnum main = %d, sub =%d\n", wk->NowBmpWinNum[0], wk->NowBmpWinNum[1]);
	PhcLinkBmp_Exit( wk, PL_BMP_PAGE_B );		// BMPウィンドウ開放
	PhcLinkBmp_Exit( wk, PL_BMP_PAGE_A );		// BMPウィンドウ開放
	BgExit( wk->bgl );			// BGL削除
	StopTP();						// タッチパネル終了
	DellVramTransferManager();

	PhcLinkBmp_MenuStrRelease( wk );

	MsgManRelease( wk );			// 文字列バッファ・マネージャ解放
	// タッチフォント解放
	FontProc_UnloadFont( FONT_TOUCH );

	sys_VBlankFuncChange( NULL, NULL );		// VBlankセット


	wk->crp = NULL;
}


//--------------------------------------------------------------------------------------------
/**
 * @brief	プロセス関数：メイン
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT PhcLinkProc_Main( PROC * proc, int * seq )
{
	PHCLINK_WORK * wk  = PROC_GetWork( proc );

	switch( *seq ){
	case SEQ_IN:

		// フェード待ち
		if( WIPE_SYS_EndCheck() == TRUE ){
			// モードで分岐する予定
			*seq = SEQ_MAINSEQ_INIT;
			OS_Printf( "heap remain = %d\n", sys_GetHeapFreeSize(HEAPID_PHC_LINK));
		}
		break;

	// メインシーケンス初期化
	case SEQ_MAINSEQ_INIT:
		*seq = SubSeqFuncTbl[wk->mainseq][0]( wk );
		break;
	// メインシーケンスメイン
	case SEQ_MAINSEQ_MAIN:
		*seq = SubSeqFuncTbl[wk->mainseq][1]( wk );

		// 上画面BG1面オフセットを随時セット
		GF_BGL_ScrollSet( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_SET, wk->Bg1SubHOffset );

//		if(sys.trg&PAD_BUTTON_DEBUG){
//			MakePattiiruBuchi( (unsigned char*)pmdp_327_buchi_64x48, 0 );
//
//		}

		break;
	// メインシーケンス終了
	case SEQ_MAINSEQ_END:
		*seq = SubSeqFuncTbl[wk->mainseq][2]( wk );
			if(wk->mainseq_next==MAINSEQ_END_PHC){
			WIPE_SYS_Start(
				WIPE_PATTERN_WMS, WIPE_TYPE_FADEOUT, WIPE_TYPE_FADEOUT,
				WIPE_FADE_WHITE, WIPE_DEF_DIV, WIPE_DEF_SYNC, HEAPID_PHC_LINK );

			*seq = SEQ_OUT;
		}else{
			wk->mainseq = wk->mainseq_next;
			PhcLinkBmp_DumpBmpSet( wk );
		}
		break;

	case SEQ_OUT:
		if( WIPE_SYS_EndCheck() == TRUE ){
			return PROC_RES_FINISH;
		}
		break;

	}

//	PhcLinkObj_SubButtonEffMain( wk );
	if(wk->crp!=NULL){
		CATS_Draw( wk->crp );
	}
	return PROC_RES_CONTINUE;
}

extern const PROC_DATA TitleProcData;
extern void		Main_SetNextProc(FSOverlayID ov_id, const PROC_DATA * proc_data);
FS_EXTERN_OVERLAY( title );


//--------------------------------------------------------------------------------------------
/**
 * @brief	プロセス関数：終了
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT PhcLinkProc_End( PROC * proc, int * seq )
{
	PHCLINK_WORK * wk  = PROC_GetWork( proc );

	// 会話ウインドウスキップ設定
	MsgPrintSkipFlagSet( MSG_SKIP_OFF );
	MsgPrintTouchPanelFlagSet( MSG_TP_OFF );

	// BG.OAM処理解放
	PhcLink_ResourceExit( wk );

	PROC_FreeWork( proc );				// ワーク開放

	sys_VBlankFuncChange( NULL, NULL );		// VBlankセット



	sys_DeleteHeap( HEAPID_PHC_LINK );

	// リセット有効に
	sys_SoftResetOK( SOFTRESET_TYPE_PHC );

	// タイトルに戻る
	Main_SetNextProc( FS_OVERLAY_ID(title), &TitleProcData );

	return PROC_RES_FINISH;
}



//============================================================================================
//	セーブデータ操作
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * @brief	セーブデータから必要なデータを取り出す
 *
 * @param	wk		ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void SaveDataGet( PHCLINK_WORK * wk )
{
	wk->myitem     = SaveData_GetMyItem( wk->savedata );
	wk->mystatus   = SaveData_GetMyStatus( wk->savedata );
	wk->config     = SaveData_GetConfig( wk->savedata );
	wk->phc_svdata = SaveData_GetPhcSaveData( wk->savedata );
	wk->zukan	   = SaveData_GetZukanWork( wk->savedata );
}



//============================================================================================
//	設定
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * @brief	 VBlank関数
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void VBlankFunc( void * work )
{
	PHCLINK_WORK * wk = work;

	GF_BGL_VBlankFunc( wk->bgl );

	// セルアクター
	DoVramTransferManager();	// Vram転送マネージャー実行
	CATS_RenderOamTrans();

	OS_SetIrqCheckFlag( OS_IE_V_BLANK );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	 VRAM設定
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void VramBankSet(void)
{
	GF_BGL_DISPVRAM tbl = {
		GX_VRAM_BG_128_B,				// メイン2DエンジンのBG
		GX_VRAM_BGEXTPLTT_NONE,			// メイン2DエンジンのBG拡張パレット

		GX_VRAM_SUB_BG_128_C,			// サブ2DエンジンのBG
		GX_VRAM_SUB_BGEXTPLTT_NONE,		// サブ2DエンジンのBG拡張パレット

		GX_VRAM_OBJ_64_E,				// メイン2DエンジンのOBJ
		GX_VRAM_OBJEXTPLTT_NONE,		// メイン2DエンジンのOBJ拡張パレット

		GX_VRAM_SUB_OBJ_16_I,			// サブ2DエンジンのOBJ
		GX_VRAM_SUB_OBJEXTPLTT_NONE,	// サブ2DエンジンのOBJ拡張パレット

		GX_VRAM_TEX_0_A,				// テクスチャイメージスロット
		GX_VRAM_TEXPLTT_0_F				// テクスチャパレットスロット
	};
	GF_Disp_SetBank( &tbl );

//	GX_SetOBJVRamModeChar( GX_OBJVRAMMODE_CHAR_2D );	// 2D mapping mode
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	 BG設定
 *
 * @param	bgl		BGLデータ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgInit( GF_BGL_INI * bgl )
{
	{	// BG SYSTEM
		GF_BGL_SYS_HEADER BGsys_data = {
			GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BGMODE_0, GX_BG0_AS_3D,
		};
		GF_BGL_InitBG( &BGsys_data );
	}

	// メイン面初期化(下画面）
	{
		static const GF_BGL_BGCNT_HEADER TextBgCntDatM[] = {
			// 3D( BG0 )

			// TEXT ( BG1 )
			{
				0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
				1, 0, 0, FALSE
			},
			// WIN_FRAME( BG2 )
			{
				0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xf000, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
				2, 0, 0, FALSE
			},
			// BG ( BG3 )
			{
				0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xe800, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
				3, 0, 0, FALSE
			},
		};
		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME1_M, &TextBgCntDatM[0], GF_BGL_MODE_TEXT );
		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME2_M, &TextBgCntDatM[1], GF_BGL_MODE_TEXT );
		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME3_M, &TextBgCntDatM[2], GF_BGL_MODE_TEXT );

		GF_BGL_ScrClear( bgl, GF_BGL_FRAME1_M );
		GF_BGL_ScrClear( bgl, GF_BGL_FRAME2_M );
		GF_BGL_ScrClear( bgl, GF_BGL_FRAME3_M );
	}


	// サブ面初期化（上画面）
	{
		static const GF_BGL_BGCNT_HEADER TextBgCntDatS[] = {
			// FONT (BG0)
			{
				0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
				0, 0, 0, FALSE
			},
			// WIN FRAME (BG1)
			{
				0, 0, 0x1000, 0, GF_BGL_SCRSIZ_512x256, GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xe800, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
				1, 0, 0, FALSE
			},
			// BACK GROUND (BG2)
			{
				0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xe000, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
				2, 0, 0, FALSE
			},
		};

		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME0_S, &TextBgCntDatS[0], GF_BGL_MODE_TEXT );
		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME1_S, &TextBgCntDatS[1], GF_BGL_MODE_TEXT );
		GF_BGL_BGControlSet( bgl, GF_BGL_FRAME2_S, &TextBgCntDatS[2], GF_BGL_MODE_TEXT );

		GF_BGL_ScrClear( bgl, GF_BGL_FRAME0_S );
		GF_BGL_ScrClear( bgl, GF_BGL_FRAME1_S );
		GF_BGL_ScrClear( bgl, GF_BGL_FRAME2_S );

		GF_BGL_ClearCharSet( GF_BGL_FRAME0_S, 32, 0, HEAPID_PHC_LINK );
		GF_BGL_ClearCharSet( GF_BGL_FRAME1_S, 32, 0, HEAPID_PHC_LINK );
		GF_BGL_ClearCharSet( GF_BGL_FRAME2_S, 32, 0, HEAPID_PHC_LINK );

	}





}

//--------------------------------------------------------------------------------------------
/**
 * @brief	 BG解放
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgExit( GF_BGL_INI * bgl )
{
	GF_Disp_GX_VisibleControl(
		GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_BG2 |
		GX_PLANEMASK_BG3 | GX_PLANEMASK_OBJ, VISIBLE_OFF );
	GF_Disp_GXS_VisibleControl(
		GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_BG3 | GX_PLANEMASK_OBJ, VISIBLE_OFF );

	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME2_S );
	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME1_S );
	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME0_S );

	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME3_M );
	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME2_M );
	GF_BGL_BGControlExit( bgl, GF_BGL_FRAME1_M );

	sys_FreeMemory( HEAPID_PHC_LINK, bgl );
}

//--------------------------------------------------------------------------------------------
/**
 * @brief	 グラフィックデータセット
 *
 * @param	wk		バッグ画面のワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgGraphicSet( PHCLINK_WORK * wk )
{
	// ハンドルオープン
	ARCHANDLE *handle = ArchiveDataHandleOpen( ARC_PHCLINK_GRA, HEAPID_PHC_LINK );

	// ----------- メイン画面 -------------------

	ArcUtil_HDL_BgCharSet( handle, NARC_phc_ds_phcds_bg_d_lz_ncgr, wk->bgl, GF_BGL_FRAME3_M, 0, 0, 1, HEAPID_PHC_LINK );
	ArcUtil_HDL_ScrnSet(   handle, NARC_phc_ds_phcds_bg_d_lz_nscr, wk->bgl, GF_BGL_FRAME3_M, 0, 0, 1, HEAPID_PHC_LINK );
	ArcUtil_HDL_PalSet(    handle, NARC_phc_ds_phcds_bg_s_nclr, PALTYPE_MAIN_BG, 0, 0, HEAPID_PHC_LINK );

	TalkFontPaletteLoad( PALTYPE_MAIN_BG, PHCLINK_TALK_FONT_PAL * 32, HEAPID_PHC_LINK );

	// メニューウィンドウセット
//	MenuWinGraphicSet( wk->bgl, GF_BGL_FRAME0_M, MENU_WIN_CGX_NUM, MENU_WIN_PAL, 0, HEAPID_PHC_LINK );

	// 会話ウィンドウセット
	TalkWinGraphicSet(
		wk->bgl, GF_BGL_FRAME1_M, TALK_WIN_CGX_NUM,
		TALK_WIN_PAL, CONFIG_GetWindowType(wk->config), HEAPID_PHC_LINK );


	// ------------ サブ画面 ------------------
	// パレット
	ArcUtil_HDL_PalSet( handle, NARC_phc_ds_phcds_bg_u_nclr, PALTYPE_SUB_BG, 0, 0, HEAPID_PHC_LINK );

	// 会話フォントパレット
	TalkFontPaletteLoad( PALTYPE_SUB_BG, PHCLINK_TALK_FONT_PAL * 32, HEAPID_PHC_LINK );

	// キャラ
	ArcUtil_HDL_BgCharSet(	handle, NARC_phc_ds_phcds_bg_u_lz_ncgr, wk->bgl, GF_BGL_FRAME2_S, 0, 0, 1, HEAPID_PHC_LINK );
	ArcUtil_HDL_ScrnSet(	handle, NARC_phc_ds_phcds_bg_u_lz_nscr, wk->bgl, GF_BGL_FRAME2_S, 0, 0, 1, HEAPID_PHC_LINK );

	// 会話ウィンドウセット
	TalkWinGraphicSet(
		wk->bgl, GF_BGL_FRAME0_S, TALK_WIN_CGX_NUM,
		TALK_WIN_PAL, CONFIG_GetWindowType(wk->config), HEAPID_PHC_LINK );


	// ハンドルクローズ
	ArchiveDataHandleClose( handle );

}

//--------------------------------------------------------------------------------------------
/**
 * @brief	 メッセージ関連作成
 *
 * @param	wk		PHC画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void MsgManCreate( PHCLINK_WORK * wk )
{


	// メッセージマネージャ作成
	wk->msg_man  = MSGMAN_Create( MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_phc_com_dat, HEAPID_PHC_LINK );
	wk->item_man = MSGMAN_Create( MSGMAN_TYPE_DIRECT, ARC_MSG, NARC_msg_itemname_dat, HEAPID_PHC_LINK );

	// ワードセットマネージャ作成
//	wk->wset = WORDSET_Create( HEAPID_PHC_LINK );
	wk->wset = WORDSET_CreateEx( 16, WORDSET_DEFAULT_BUFLEN, HEAPID_PHC_LINK );

	// メッセージ展開用バッファ
	wk->TalkStr = STRBUF_Create( PHCLINK_TALKMSG_MAX, HEAPID_PHC_LINK );
}


//------------------------------------------------------------------
/**
 * @brief   文字列バッファ・マネージャ解放
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void MsgManRelease( PHCLINK_WORK *wk )
{
	// 会話文字列用バッファ解放
	STRBUF_Delete( wk->TalkStr );

	// メッセージマネージャ・ワードセットマネージャ解放
	MSGMAN_Delete( wk->item_man );
	MSGMAN_Delete( wk->msg_man );
	WORDSET_Delete( wk->wset );

}


//==============================================================================
/**
 * @brief   スクリーン転送
 *
 * @param   wk			PHC画面ワーク
 * @param   frame		フレーム
 * @param   screen_no	スクリーンデータのenum
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_BgGraphicSet( PHCLINK_WORK *wk, int frame, int screen_no )
{
	ArcUtil_ScrnSet( ARC_PHCLINK_GRA, screen_no, wk->bgl, frame, 0, 0, 1, HEAPID_PHC_LINK );

}


#if 0
//------------------------------------------------------------------
/**
 * @brief   サブシーケンス遷移処理
 *
 * @param   wk
 *
 * @retval  int
 */
//------------------------------------------------------------------
static int MainSeqFunc( PHCLINK_WORK *wk )
{
	if(sys.trg&PAD_BUTTON_DECIDE){

		wk->mainseq = SubSeqFuncTbl[wk->mainseq]( wk );

		// フェードアウト開始
//		WIPE_SYS_Start(
//			WIPE_PATTERN_WMS, WIPE_TYPE_FADEOUT, WIPE_TYPE_FADEOUT,
//			WIPE_FADE_BLACK, WIPE_DEF_DIV, WIPE_DEF_SYNC, HEAPID_PHC_LINK );

//		return SEQ_OUT;
	}

	return SEQ_MAIN;
}
#endif


//--------------------------------------------------------------------------------------------
/**
 * @brief	 タッチパネルコントロール
 *
 * @param	wk		バッグ画面のワーク
 * @param   mode    TOUCH_MODE_NORMAL=0,	// 通常時
 *					TOUCH_MODE_SELECT,		// どうぐ選択後の選択肢表示
 *					TOUCH_MODE_CHANGE,		// どうぐ入れ替え時
 *					TOUCH_MODE_NUMBER,		// 数値入力時
 *
 *
 * @retval	"TRUE = 押された"
 * @retval	"FALSE = 押されていない"
 */
//--------------------------------------------------------------------------------------------
static u32 TouchButtonControl( PHCLINK_WORK * wk, int mode )
{
	static const RECT_HIT_TBL *TouchTable[]={
//		TouchModeSelectTbl,				// モード選択用
//		TouchButtonNormalTbl,       	// 通常時
//		TouchButtonSaleNumInputTbl,		// 数値入力時
		EnterButtonRect,
	};

	int ret = GF_TP_RectHitTrg( TouchTable[mode] );

//	int	ret = SubPokeButtonCheck( wk );

	if(ret!=RECT_HIT_NONE){
		MORI_PRINT("touch  = %d\n", ret);
	}

	return ret;
}



//==============================================================================
/**
 * @brief   PHCライブラリ初期化
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_IrcSystemInit( PHCLINK_WORK *wk )
{
	MYSTATUS *mystatus = SaveData_GetMyStatus( wk->savedata );
	// 自分の名前取得
	STRBUF *myname     = MyStatus_CreateNameString( mystatus, HEAPID_PHC_LINK );


	/****************************************************************************
	ステータス情報のセット
	****************************************************************************/
	wk->phcsys.myStatusDS.country          = PHC_LANG_JAPANESE;

#if (PM_VERSION == VERSION_GOLD )
		wk->phcsys.myStatusDS.romVersion       = VERSION_GOLD;//
#else
		wk->phcsys.myStatusDS.romVersion       = VERSION_SILVER;//
#endif
	wk->phcsys.myStatusDS.entryFlag        = 0;
	wk->phcsys.myStatusDS.distributeNumber = 0;
	wk->phcsys.myStatusDS.trainerId        = MyStatus_GetID( wk->mystatus); // トレーナーID
	// トレーナー名をコピー
	STRBUF_GetStringCode( myname, (STRCODE*)wk->phcsys.myStatusDS.trainerName,  PERSON_NAME_SIZE+EOM_SIZE );
	wk->phcsys.myStatusDS.country_poke     = PHC_LANG_JAPANESE;

#if (PM_VERSION == VERSION_GOLD )
	wk->phcsys.myStatusDS.romVersion_poke  = VERSION_GOLD;//
#else
	wk->phcsys.myStatusDS.romVersion_poke  = VERSION_SILVER;//
#endif
	// PHC-ID
	MI_CpuCopyFast( PhcSvData_GetIdPtr(wk->phc_svdata),wk->phcsys.myStatusDS.PHCUniqueId, PHC_ID_LEN);

	/****************************************************************************
	PHC ライブラリ関係
	****************************************************************************/
	PHC_Init(wk->phcsys.stack, PHC_STACK_SIZE, PHC_THREAD_PRIORITY);
	PHC_SetStatusBuffer(&wk->phcsys.myStatusDS, &wk->phcsys.myStatusPHC);
	PHC_SetCompressBuffer(wk->phcsys.compressBuffer);

	STRBUF_Delete( myname );

}


//==============================================================================
/**
 * @brief   PHCライブラリ終了処理
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_IrcSystemExit( PHCLINK_WORK *wk )
{
	PHC_Dispose();
}



//==============================================================================
/**
 * @brief   PHC送信情報構築(初めてのPHC初期化用）
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_IRCInitSetup( PHCLINK_WORK *wk )
{
	set_image(  wk, &wk->phcsys.myImageData );
	set_course( &wk->phcsys.myCourse, wk );
	_tr_house_data_make( wk );

	OS_Printf( "phcinitdata=%d\n", sizeof(PHCImageData) );


}

//==============================================================================
/**
 * @brief   PHC送信情報構築（ポケモン送信のみ）
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_IRCSendSetup( PHCLINK_WORK *wk )
{
	set_course( &wk->phcsys.myCourse, wk );
	_tr_house_data_make( wk );
}


//------------------------------------------------------------------
/**
 * @brief   トレーナーハウスデータを作成
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void _tr_house_data_make( PHCLINK_WORK *wk )
{
	TrHousePHC_SetRecordData( wk->savedata, wk->phcsys.myRecord.record );
	wk->phcsys.myRecord.country = PHC_LANG_JAPANESE;

#if (PM_VERSION == VERSION_GOLD )
	wk->phcsys.myRecord.romVersion = VERSION_GOLD;
#else
	wk->phcsys.myRecord.romVersion = VERSION_SILVER;
#endif
	MI_CpuCopyFast( PhcSvData_GetIdPtr( wk->phc_svdata ), wk->phcsys.myRecord.id, PHC_ID_LEN );
}



#include "inittext\phc_b_cname_01.h"
#include "inittext\phc_b_iname_01.h"
#include "inittext\phc_b_pname_01.h"
#include "inittext\phc_cname.h"
#include "inittext\phc_c_iname_01.h"
#include "inittext\phc_c_iname_02.h"
#include "inittext\phc_c_iname_03.h"
#include "inittext\phc_c_iname_04.h"
#include "inittext\phc_c_iname_05.h"
#include "inittext\phc_c_iname_06.h"
#include "inittext\phc_c_iname_07.h"
#include "inittext\phc_c_iname_08.h"
#include "inittext\phc_c_iname_09.h"
#include "inittext\phc_c_iname_10.h"
#include "inittext\phc_c_pname_01.h"
#include "inittext\phc_c_pname_02.h"
#include "inittext\phc_c_pname_03.h"
#include "inittext\phc_menu_01.h"
#include "inittext\phc_menu_02.h"
#include "inittext\phc_menu_03.h"
#include "inittext\phc_menu_04.h"
#include "inittext\phc_menu_05.h"
#include "inittext\phc_menu_06.h"
#include "inittext\phc_mes_01.h"
#include "inittext\phc_mes_02.h"
#include "inittext\phc_mes_03.h"
#include "inittext\phc_mes_04.h"
#include "inittext\phc_mes_05.h"
#include "inittext\phc_mes_06.h"
#include "inittext\phc_mes_07.h"
#include "inittext\phc_mes_08.h"
#include "inittext\phc_mes_09.h"
#include "inittext\phc_mes_10.h"
#include "inittext\phc_mes_11.h"
#include "inittext\phc_mes_12.h"
#include "inittext\phc_mes_13.h"
#include "inittext\phc_mes_14.h"
#include "inittext\phc_mes_15.h"
#include "inittext\phc_mes_16.h"
#include "inittext\phc_mes_17.h"
#include "inittext\phc_mes_18.h"
#include "inittext\phc_mes_19.h"
#include "inittext\phc_mes_20.h"
#include "inittext\phc_mes_21.h"
#include "inittext\phc_mes_22.h"
#include "inittext\phc_mes_23.h"
#include "inittext\phc_mes_24.h"
#include "inittext\phc_mes_25.h"
#include "inittext\phc_mes_26.h"
#include "inittext\phc_mes_27.h"
#include "inittext\phc_mes_28.h"
#include "inittext\phc_mes_29.h"
#include "inittext\phc_mes_30.h"
#include "inittext\phc_mes_31.h"
#include "inittext\phc_mes_32.h"
#include "inittext\phc_mes_33.h"
#include "inittext\phc_mes_34.h"
#include "inittext\phc_mes_35.h"
#include "inittext\phc_mes_36.h"
#include "inittext\phc_mes_37.h"
#include "inittext\phc_mes_38.h"
#include "inittext\phc_mes_39.h"
#include "inittext\phc_mes_40.h"
#include "inittext\phc_mes_41.h"
#include "inittext\phc_mes_42.h"
#include "inittext\phc_mes_43.h"
#include "inittext\phc_mes_44.h"
#include "inittext\phc_mes_45.h"
#include "inittext\phc_mes_46.h"
#include "inittext\phc_mes_47.h"
#include "inittext\phc_mes_48.h"
#include "inittext\phc_mes_49.h"
#include "inittext\phc_mes_50.h"
#include "inittext\phc_mes_51.h"
#include "inittext\phc_mes_52.h"
#include "inittext\phc_mes_53.h"
#include "inittext\phc_mes_54.h"
#include "inittext\phc_mes_55.h"
#include "inittext\phc_mes_56.h"
#include "inittext\phc_mes_57.h"
#include "inittext\phc_mes_58.h"
#include "inittext\phc_mes_59.h"
#include "inittext\phc_mes_60.h"
#include "inittext\phc_mes_61.h"
#include "inittext\phc_mes_62.h"
#include "inittext\phc_mes_63.h"
#include "inittext\phc_mes_64.h"
#include "inittext\phc_mes_65.h"
#include "inittext\phc_mes_66.h"
#include "inittext\phc_mes_67.h"
#include "inittext\phc_mes_68.h"
#include "inittext\phc_mes_69.h"
#include "inittext\phc_name.h"
#include "inittext\phc_pname_01.h"
#include "inittext\phc_sp_cname_01.h"
#include "inittext\phc_sp_iname_01.h"
#include "inittext\phc_sp_pname_01.h"
#include "initimage\phc_ball_01.h"
#include "initimage\phc_ball_02.h"
#include "initimage\phc_ball_m.h"
#include "initimage\phc_battery.h"
#include "initimage\phc_battle_command.h"
#include "initimage\phc_battle_hit01.h"
#include "initimage\phc_battle_hit02.h"
#include "initimage\phc_battle_meter.h"
#include "initimage\phc_battle_smoke.h"
#include "initimage\phc_battle_star.h"
#include "initimage\phc_card_icon.h"
#include "initimage\phc_check_icon.h"
#include "initimage\phc_check_item.h"
#include "initimage\phc_check_map.h"
#include "initimage\phc_check_present.h"
#include "initimage\phc_com_icon.h"
#include "initimage\phc_com_note.h"
#include "initimage\phc_com_phc.h"
#include "initimage\phc_com_wave.h"
#include "initimage\phc_course_01.h"
#include "initimage\phc_course_02.h"
#include "initimage\phc_course_03.h"
#include "initimage\phc_course_04.h"
#include "initimage\phc_course_05.h"
#include "initimage\phc_course_06.h"
#include "initimage\phc_course_07.h"
#include "initimage\phc_course_08.h"
#include "initimage\phc_cursor_d01.h"
#include "initimage\phc_cursor_d02.h"
#include "initimage\phc_cursor_d03.h"
#include "initimage\phc_cursor_k01.h"
#include "initimage\phc_cursor_k02.h"
#include "initimage\phc_cursor_l01.h"
#include "initimage\phc_cursor_l02.h"
#include "initimage\phc_cursor_l03.h"
#include "initimage\phc_cursor_l04.h"
#include "initimage\phc_cursor_r01.h"
#include "initimage\phc_cursor_r02.h"
#include "initimage\phc_cursor_r03.h"
#include "initimage\phc_cursor_r04.h"
#include "initimage\phc_cursor_return.h"
#include "initimage\phc_cursor_return2.h"
#include "initimage\phc_cursor_u01.h"
#include "initimage\phc_cursor_u02.h"
#include "initimage\phc_cursor_u03.h"
#include "initimage\phc_dowsing_grass01.h"
#include "initimage\phc_dowsing_grass02.h"
#include "initimage\phc_dowsing_icon.h"
#include "initimage\phc_dowsing_remaining.h"
#include "initimage\phc_dowsing_times.h"
#include "initimage\phc_end_hours.h"
#include "initimage\phc_font_colon.h"
#include "initimage\phc_font_minus.h"
#include "initimage\phc_font_number00.h"
#include "initimage\phc_font_number01.h"
#include "initimage\phc_font_number02.h"
#include "initimage\phc_font_number03.h"
#include "initimage\phc_font_number04.h"
#include "initimage\phc_font_number05.h"
#include "initimage\phc_font_number06.h"
#include "initimage\phc_font_number07.h"
#include "initimage\phc_font_number08.h"
#include "initimage\phc_font_number09.h"
#include "initimage\phc_font_slush.h"
#include "initimage\phc_font_w.h"
#include "initimage\phc_initialize01.h"
#include "initimage\phc_initialize02.h"
#include "initimage\phc_initialize03.h"
#include "initimage\phc_initialize04.h"
#include "initimage\phc_initialize05.h"
#include "initimage\phc_initialize_wave.h"
#include "initimage\phc_item_01.h"
#include "initimage\phc_item_02.h"
#include "initimage\phc_map_01.h"
#include "initimage\phc_poketre_encount01.h"
#include "initimage\phc_poketre_encount02.h"
#include "initimage\phc_poketre_encount03.h"
#include "initimage\phc_poketre_find.h"
#include "initimage\phc_poketre_grass.h"
#include "initimage\phc_poketre_icon.h"
#include "initimage\phc_poke_01.h"
#include "initimage\phc_present_01.h"
#include "initimage\phc_set_contrast.h"
#include "initimage\phc_set_icon.h"
#include "initimage\phc_set_meter.h"
#include "initimage\phc_set_off.h"
#include "initimage\phc_set_on.h"
#include "initimage\phc_set_on2.h"
#include "initimage\phc_set_sound.h"
#include "initimage\phc_speak_01.h"
#include "initimage\phc_speak_02.h"
#include "initimage\phc_speak_03.h"
#include "initimage\phc_speak_04.h"
#include "initimage\phc_speak_05.h"
#include "initimage\phc_speak_06.h"
#include "initimage\phc_speak_07.h"
#include "initimage\phc_stamp_01.h"
#include "initimage\phc_stamp_02.h"
#include "initimage\phc_stamp_03.h"
#include "initimage\phc_stamp_04.h"
#include "initimage\phc_status_am.h"
#include "initimage\phc_status_coursename.h"
#include "initimage\phc_status_day.h"
#include "initimage\phc_status_days.h"
#include "initimage\phc_status_humanname.h"
#include "initimage\phc_status_pm.h"
#include "initimage\phc_status_step.h"




/******************************************************************************
通信で渡すパラメータテーブル
******************************************************************************/
#define NUM_GS_MAP	(20)			///< ワットで増えるPHCコースの数

#define ITEM_NAME_BMP_W		( 12 )	///< どうぐ名BMP横幅
#define POKE_NAME_BMP_W		( 10 )	///< ポケモン名BMP横幅
#define COURSE_NAME_BMP_W	( 10 )	///< コース名BMP横幅
#define HERO_NAME_BMP_W		( 10 )	///< 主人公名BMP横幅

enum{
	BMP_ITEM_NAME0=0,
	BMP_ITEM_NAME1,
	BMP_ITEM_NAME2,
	BMP_ITEM_NAME3,
	BMP_ITEM_NAME4,
	BMP_ITEM_NAME5,
	BMP_ITEM_NAME6,
	BMP_ITEM_NAME7,
	BMP_ITEM_NAME8,
	BMP_ITEM_NAME9,
	BMP_POKE_NAME0,
	BMP_POKE_NAME1,
	BMP_POKE_NAME2,
	BMP_COURSE_NAME,
	BMP_MYPOKE_NAME,
};

static const u8 name_w_tbl[]={
	ITEM_NAME_BMP_W,	///< どうぐ名1
	ITEM_NAME_BMP_W,	///< どうぐ名2
	ITEM_NAME_BMP_W,	///< どうぐ名3
	ITEM_NAME_BMP_W,	///< どうぐ名4
	ITEM_NAME_BMP_W,	///< どうぐ名5
	ITEM_NAME_BMP_W,	///< どうぐ名6
	ITEM_NAME_BMP_W,	///< どうぐ名7
	ITEM_NAME_BMP_W,	///< どうぐ名8
	ITEM_NAME_BMP_W,	///< どうぐ名9
	ITEM_NAME_BMP_W,	///< どうぐ名10
	POKE_NAME_BMP_W,	///< エンカウントポケモン名１
	POKE_NAME_BMP_W,	///< エンカウントポケモン名２
	POKE_NAME_BMP_W,	///< エンカウントポケモン名３
	COURSE_NAME_BMP_W,	///< コース名
	POKE_NAME_BMP_W,	///< 自分のポケモン名
};


static const unsigned char *course_graphic_tbl[]={
	phc_course_01_32x24,
	phc_course_02_32x24,
	phc_course_03_32x24,
	phc_course_04_32x24,
	phc_course_05_32x24,
	phc_course_06_32x24,
	phc_course_07_32x24,
	phc_course_08_32x24,
};


extern void setup_sound(PHCSoundData *p);

#define PHC_STRING_BUF	( 96*16/8*2)	///< メッセージバッファ

/******************************************************************************
初期化時の画像データをセットアップ
******************************************************************************/
static void set_image( PHCLINK_WORK *wk, PHCImageData *myImageData )
{
	GF_BGL_BMPWIN	bmpwin;
	u8 *buf = sys_AllocMemory( HEAPID_PHC_LINK, PHC_STRING_BUF );

	// 自分の名前画像作成用
	GF_BGL_BmpWinAdd(	wk->bgl, &bmpwin, GF_BGL_FRAME1_M,	0, 0, HERO_NAME_BMP_W, 2, 0, 0 );
	GF_BGL_BmpWinDataFill( &bmpwin,0 );


  MI_CpuCopy8(phc_font_number00_8x16,   &myImageData->font[0], 32);
	MI_CpuCopy8(phc_font_number01_8x16, &myImageData->font[32*1], 32);
	MI_CpuCopy8(phc_font_number02_8x16, &myImageData->font[32*2], 32);
	MI_CpuCopy8(phc_font_number03_8x16, &myImageData->font[32*3], 32);
	MI_CpuCopy8(phc_font_number04_8x16, &myImageData->font[32*4], 32);
	MI_CpuCopy8(phc_font_number05_8x16, &myImageData->font[32*5], 32);
	MI_CpuCopy8(phc_font_number06_8x16, &myImageData->font[32*6], 32);
	MI_CpuCopy8(phc_font_number07_8x16, &myImageData->font[32*7], 32);
	MI_CpuCopy8(phc_font_number08_8x16, &myImageData->font[32*8], 32);
	MI_CpuCopy8(phc_font_number09_8x16, &myImageData->font[32*9], 32);

	MI_CpuCopy8(phc_font_colon_8x16, &myImageData->font[32*10], 32);
	MI_CpuCopy8(phc_font_minus_8x16, &myImageData->font[32*11], 32);
	MI_CpuCopy8(phc_font_slush_8x16, &myImageData->font[32*12], 32);
	MI_CpuCopy8(phc_font_w_16x16, &myImageData->watt[0], 64);
	/**************************************************************************
    カーソル
	**************************************************************************/
	MI_CpuCopy8(phc_cursor_u01_8x8, &myImageData->arrow[16*0], 16);
	MI_CpuCopy8(phc_cursor_u02_8x8, &myImageData->arrow[16*1], 16);
	MI_CpuCopy8(phc_cursor_u03_8x8, &myImageData->arrow[16*2], 16);

	MI_CpuCopy8(phc_cursor_d01_8x8, &myImageData->arrow[16*3], 16);
	MI_CpuCopy8(phc_cursor_d02_8x8, &myImageData->arrow[16*4], 16);
	MI_CpuCopy8(phc_cursor_d03_8x8, &myImageData->arrow[16*5], 16);

	MI_CpuCopy8(phc_cursor_l01_8x8, &myImageData->arrow[16*6], 16);
	MI_CpuCopy8(phc_cursor_l02_8x8, &myImageData->arrow[16*7], 16);
	MI_CpuCopy8(phc_cursor_l03_8x8, &myImageData->arrow[16*8], 16);

	MI_CpuCopy8(phc_cursor_r01_8x8, &myImageData->arrow[16*9], 16);
	MI_CpuCopy8(phc_cursor_r02_8x8, &myImageData->arrow[16*10], 16);
	MI_CpuCopy8(phc_cursor_r03_8x8, &myImageData->arrow[16*11], 16);

	MI_CpuCopy8(phc_cursor_l04_8x16, &myImageData->arrowBig[32*0], 32);
	MI_CpuCopy8(phc_cursor_r04_8x16, &myImageData->arrowBig[32*1], 32);
	MI_CpuCopy8(phc_cursor_return_8x16, &myImageData->arrowBig[32*2], 32);

	MI_CpuCopy8(phc_cursor_k01_8x8, myImageData->next_cursor,16);
	MI_CpuCopy8(phc_cursor_k02_8x8, myImageData->next_cursor_mask,8);

	/**************************************************************************
	**************************************************************************/
	MI_CpuCopy8(phc_ball_01_8x8, &myImageData->ball[0], 16); // 獲得ポケモン(ボール)
	MI_CpuCopy8(phc_ball_02_8x8, &myImageData->ballDist[0], 16); // 配布ポケモン(ボール)

	MI_CpuCopy8(phc_item_01_8x8, &myImageData->treasure[0], 16); // アイテム(宝箱)
	MI_CpuCopy8(phc_item_02_8x8, &myImageData->treasureDist[0], 16); // 配布アイテム(宝箱)

	MI_CpuCopy8(phc_map_01_8x8, &myImageData->mapDist[0], 16); // 配布スタンプ
	MI_CpuCopy8(phc_stamp_01_8x8, &myImageData->stampDist[0], 16); // 配布スタンプ
	MI_CpuCopy8(phc_stamp_02_8x8, &myImageData->stampDist[16], 16); // 配布スタンプ
	MI_CpuCopy8(phc_stamp_03_8x8, &myImageData->stampDist[32], 16); // 配布スタンプ
	MI_CpuCopy8(phc_stamp_04_8x8, &myImageData->stampDist[48], 16); // 配布スタンプ

	MI_CpuCopy8(phc_present_01_8x8, &myImageData->present[0], 16); // バッテリー
	MI_CpuCopy8(phc_battery_8x8, &myImageData->battery[0], 16); // バッテリー
	/**************************************************************************
    メニュー画面
	**************************************************************************/
	MI_CpuCopy8(phc_poketre_icon_16x16, &myImageData->icon[64*0], 64); // ダウジングアイコン
	MI_CpuCopy8(phc_dowsing_icon_16x16, &myImageData->icon[64*1], 64); // ポケトレアイコン
	MI_CpuCopy8(phc_com_icon_16x16, &myImageData->icon[64*2], 64); // つうしんアイコン
	MI_CpuCopy8(phc_card_icon_16x16, &myImageData->icon[64*3], 64); // 情報アイコン
	MI_CpuCopy8(phc_check_icon_16x16, &myImageData->icon[64*4], 64); // もちものアイコン
	MI_CpuCopy8(phc_set_icon_16x16, &myImageData->icon[64*5], 64); // せっていアイコン
//	MI_CpuCopy8(phc_return_icon_16x16, &myImageData->icon[64*5], 64); // 配布スタンプ

	MI_CpuCopy8(phc_menu_01_80x16, &myImageData->list[320*0], 320); //
	MI_CpuCopy8(phc_menu_02_80x16, &myImageData->list[320*1], 320); //
	MI_CpuCopy8(phc_menu_03_80x16, &myImageData->list[320*2], 320); //
	MI_CpuCopy8(phc_menu_04_80x16, &myImageData->list[320*3], 320); //
	MI_CpuCopy8(phc_menu_05_80x16, &myImageData->list[320*4], 320); //
	MI_CpuCopy8(phc_menu_06_80x16, &myImageData->list[320*5], 320); //
	/**************************************************************************
    ダウジング画面
	**************************************************************************/
	MI_CpuCopy8(phc_dowsing_grass01_16x16, &myImageData->grass[0], 64); // 草(濃い)
	MI_CpuCopy8(phc_dowsing_grass02_16x16, &myImageData->grassLight[0], 64); // 草(薄い)
	MI_CpuCopy8(phc_dowsing_remaining_32x16, &myImageData->rest[0], 128); //
	MI_CpuCopy8(phc_dowsing_times_24x16, &myImageData->kai[0], 96); //
	/**************************************************************************
    ポケトレ画面
	**************************************************************************/
	MI_CpuCopy8(phc_poketre_grass_32x24, &myImageData->ptGrass[0], 192); //

	MI_CpuCopy8(phc_poketre_encount01_16x16, &myImageData->ptIcon[0], 64); //
	MI_CpuCopy8(phc_poketre_encount02_16x16, &myImageData->ptIcon[64*1], 64); //
	MI_CpuCopy8(phc_poketre_encount03_16x16, &myImageData->ptIcon[64*2], 64); //
	MI_CpuCopy8(phc_poketre_find_16x16, &myImageData->ptIcon[64*3], 64); //
	/**************************************************************************
    バトル画面
	**************************************************************************/
	MI_CpuCopy8(phc_battle_hit01_16x32, &myImageData->attack[0], 128); // 攻撃
	MI_CpuCopy8(phc_battle_hit02_16x32, &myImageData->weakPoint[0], 128); // 急所
	MI_CpuCopy8(phc_battle_smoke_32x24, &myImageData->gas[0], 192); // 煙
	MI_CpuCopy8(phc_battle_meter_8x8, &myImageData->battleMeter[0], 16); // メーター
	MI_CpuCopy8(phc_battle_star_8x8, &myImageData->star[0], 16); // 星
	MI_CpuCopy8(phc_battle_command_96x32, &myImageData->battleMenu[0], 384*2); // バトルメニュー
	/**************************************************************************
    ステータス画面
	**************************************************************************/
	MI_CpuCopy8(phc_status_humanname_16x16, &myImageData->iconName[0], 64); // 16*16
	MI_CpuCopy8(phc_status_coursename_16x16, &myImageData->course[0], 64);
	MI_CpuCopy8(phc_status_step_40x16, &myImageData->step[0], 160);
	MI_CpuCopy8(phc_status_am_32x16, &myImageData->am_pm[0], 128);
	MI_CpuCopy8(phc_status_pm_32x16, &myImageData->am_pm[128], 128);
	MI_CpuCopy8(phc_status_days_40x16, &myImageData->dayPass[0], 160);
	MI_CpuCopy8(phc_status_day_64x16, &myImageData->dayTotal[0], 256);

	// トレーナー名埋め込み
	_set_bmpwin_myname( &bmpwin, wk );
	bmp2phc( bmpwin.chrbuf, HERO_NAME_BMP_W, 2, buf, 0, 0, HERO_NAME_BMP_W*8, 16 );
	MI_CpuCopy8( buf, &myImageData->name[0], 320);

	/**************************************************************************
    アイテム確認画面
	**************************************************************************/
	MI_CpuCopy8(phc_check_item_32x24, &myImageData->itemTreasure[0], 192);
	MI_CpuCopy8(phc_check_map_32x24, &myImageData->itemMap[0], 192);
	MI_CpuCopy8(phc_check_present_32x24, &myImageData->itemPresent[0], 192);
	/**************************************************************************
    設定画面
	**************************************************************************/
	MI_CpuCopy8(phc_set_sound_40x16, &myImageData->volume[0], 160);
	MI_CpuCopy8(phc_set_contrast_40x16, &myImageData->contrast[0], 160);
	MI_CpuCopy8(phc_set_meter_8x16, &myImageData->meter[0], 32);
	MI_CpuCopy8(phc_set_on_24x16, &myImageData->se_on[0], 96);
	MI_CpuCopy8(phc_set_on2_24x16, &myImageData->se_on2[0], 96);
	MI_CpuCopy8(phc_set_off_24x16, &myImageData->se_off[0], 96);
	/**************************************************************************
    通信画面
	**************************************************************************/
	MI_CpuCopy8(phc_com_phc_32x32, &myImageData->phc[0], 256);
	MI_CpuCopy8(phc_com_wave_8x16, &myImageData->radio[0], 32);
	MI_CpuCopy8(phc_com_note_8x8, &myImageData->note[0], 16);
	/**************************************************************************
    メッセージグラフィック
	**************************************************************************/
	MI_CpuCopy8(phc_mes_01_96x16, &myImageData->message[384*0], 384);
	MI_CpuCopy8(phc_mes_02_96x16, &myImageData->message[384*1], 384);
	MI_CpuCopy8(phc_mes_03_96x16, &myImageData->message[384*2], 384);
	MI_CpuCopy8(phc_mes_04_96x16, &myImageData->message[384*3], 384);
	MI_CpuCopy8(phc_mes_05_96x16, &myImageData->message[384*4], 384);
	MI_CpuCopy8(phc_mes_06_96x16, &myImageData->message[384*5], 384);
	MI_CpuCopy8(phc_mes_07_96x16, &myImageData->message[384*6], 384);
	MI_CpuCopy8(phc_mes_08_96x16, &myImageData->message[384*7], 384);
	MI_CpuCopy8(phc_mes_09_96x16, &myImageData->message[384*8], 384);
	MI_CpuCopy8(phc_mes_10_96x16, &myImageData->message[384*9], 384);

	MI_CpuCopy8(phc_mes_11_96x16, &myImageData->message[384*10], 384);
	MI_CpuCopy8(phc_mes_12_96x16, &myImageData->message[384*11], 384);
	MI_CpuCopy8(phc_mes_13_96x16, &myImageData->message[384*12], 384);
	MI_CpuCopy8(phc_mes_14_96x16, &myImageData->message[384*13], 384);
	MI_CpuCopy8(phc_mes_15_96x16, &myImageData->message[384*14], 384);
	MI_CpuCopy8(phc_mes_16_96x16, &myImageData->message[384*15], 384);
	MI_CpuCopy8(phc_mes_17_96x16, &myImageData->message[384*16], 384);
	MI_CpuCopy8(phc_mes_18_96x16, &myImageData->message[384*17], 384);
	MI_CpuCopy8(phc_mes_19_96x16, &myImageData->message[384*18], 384);
	MI_CpuCopy8(phc_mes_20_96x16, &myImageData->message[384*19], 384);

	MI_CpuCopy8(phc_mes_21_96x16, &myImageData->message[384*20], 384);
	MI_CpuCopy8(phc_mes_22_96x16, &myImageData->message[384*21], 384);
	MI_CpuCopy8(phc_mes_23_96x16, &myImageData->message[384*22], 384);
	MI_CpuCopy8(phc_mes_24_96x16, &myImageData->message[384*23], 384);
	MI_CpuCopy8(phc_mes_25_96x16, &myImageData->message[384*24], 384);
	MI_CpuCopy8(phc_mes_26_96x16, &myImageData->message[384*25], 384);
	MI_CpuCopy8(phc_mes_27_96x16, &myImageData->message[384*26], 384);
	MI_CpuCopy8(phc_mes_28_96x16, &myImageData->message[384*27], 384);
	MI_CpuCopy8(phc_mes_29_96x16, &myImageData->message[384*28], 384);
	MI_CpuCopy8(phc_mes_30_96x16, &myImageData->message[384*29], 384);

	MI_CpuCopy8(phc_mes_31_96x16, &myImageData->message[384*30], 384);
	MI_CpuCopy8(phc_mes_32_96x16, &myImageData->message[384*31], 384);
	MI_CpuCopy8(phc_mes_33_96x16, &myImageData->message[384*32], 384);
	MI_CpuCopy8(phc_mes_34_96x16, &myImageData->message[384*33], 384);
	MI_CpuCopy8(phc_mes_35_96x16, &myImageData->message[384*34], 384);
	MI_CpuCopy8(phc_mes_36_96x16, &myImageData->message[384*35], 384);
	MI_CpuCopy8(phc_mes_37_96x16, &myImageData->message[384*36], 384);
	MI_CpuCopy8(phc_mes_38_96x16, &myImageData->message[384*37], 384);
	MI_CpuCopy8(phc_mes_39_96x16, &myImageData->message[384*38], 384);
	MI_CpuCopy8(phc_mes_40_96x16, &myImageData->message[384*39], 384);

	MI_CpuCopy8(phc_mes_41_96x16, &myImageData->message[384*40], 384);
	MI_CpuCopy8(phc_mes_42_96x16, &myImageData->message[384*41], 384);
	MI_CpuCopy8(phc_mes_43_96x16, &myImageData->message[384*42], 384);
	MI_CpuCopy8(phc_mes_44_96x16, &myImageData->message[384*43], 384);
	MI_CpuCopy8(phc_mes_45_96x16, &myImageData->message[384*44], 384);
	MI_CpuCopy8(phc_mes_46_96x16, &myImageData->message[384*45], 384);
	MI_CpuCopy8(phc_mes_47_96x16, &myImageData->message[384*46], 384);
	MI_CpuCopy8(phc_mes_48_96x16, &myImageData->message[384*47], 384);
	MI_CpuCopy8(phc_mes_49_96x16, &myImageData->message[384*48], 384);
	MI_CpuCopy8(phc_mes_50_96x16, &myImageData->message[384*49], 384);

	MI_CpuCopy8(phc_mes_51_96x16, &myImageData->message[384*50], 384);
	MI_CpuCopy8(phc_mes_52_96x16, &myImageData->message[384*51], 384);
	MI_CpuCopy8(phc_mes_53_96x16, &myImageData->message[384*52], 384);
	MI_CpuCopy8(phc_mes_54_96x16, &myImageData->message[384*53], 384);
	MI_CpuCopy8(phc_mes_55_96x16, &myImageData->message[384*54], 384);
	MI_CpuCopy8(phc_mes_56_96x16, &myImageData->message[384*55], 384);
	MI_CpuCopy8(phc_mes_57_96x16, &myImageData->message[384*56], 384);
	MI_CpuCopy8(phc_mes_58_96x16, &myImageData->message[384*57], 384);
	MI_CpuCopy8(phc_mes_59_96x16, &myImageData->message[384*58], 384);
	MI_CpuCopy8(phc_mes_60_96x16, &myImageData->message[384*59], 384);

	MI_CpuCopy8(phc_mes_61_96x16, &myImageData->message[384*60], 384);
	MI_CpuCopy8(phc_mes_62_96x16, &myImageData->message[384*61], 384);
	MI_CpuCopy8(phc_mes_63_96x16, &myImageData->message[384*62], 384);
	MI_CpuCopy8(phc_mes_64_96x16, &myImageData->message[384*63], 384);
	MI_CpuCopy8(phc_mes_65_96x16, &myImageData->message[384*64], 384);
	MI_CpuCopy8(phc_mes_66_96x16, &myImageData->message[384*65], 384);
	MI_CpuCopy8(phc_mes_67_96x16, &myImageData->message[384*66], 384);
	MI_CpuCopy8(phc_mes_68_96x16, &myImageData->message[384*67], 384);
	MI_CpuCopy8(phc_mes_69_80x16, &myImageData->message[384*68], 384);
//	MI_CpuCopy8(phc_mes_70_96x16, &myImageData->message[384*69], 384);
//	MI_CpuCopy8(phc_mes_71_80x16, &myImageData->message[384*70], 320);

	/**************************************************************************
    エンディング
	**************************************************************************/
	MI_CpuCopy8(phc_end_hours_40x16, &myImageData->ending[0], 160);
	/**************************************************************************
	**************************************************************************/
	MI_CpuCopy8(phc_speak_01_24x16, &myImageData->feeling[0], 96); // 吹き出しデータ
	MI_CpuCopy8(phc_speak_02_24x16, &myImageData->feeling[96*1], 96); // 吹き出しデータ
	MI_CpuCopy8(phc_speak_03_24x16, &myImageData->feeling[96*2], 96); // 吹き出しデータ
	MI_CpuCopy8(phc_speak_04_24x16, &myImageData->feeling[96*3], 96); // 吹き出しデータ
	MI_CpuCopy8(phc_speak_05_24x16, &myImageData->feeling[96*4], 96); // 吹き出しデータ
	MI_CpuCopy8(phc_speak_06_24x16, &myImageData->feeling[96*5], 96); // 吹き出しデータ
	MI_CpuCopy8(phc_speak_07_24x16, &myImageData->feeling[96*6], 96); // 吹き出しデータ

	/**************************************************************************
	 サウンド設定---------------------------
	**************************************************************************/
	setup_sound( &myImageData->soundData);

	sys_FreeMemoryEz( buf );
	GF_BGL_BmpWinDel(&bmpwin);
}

//------------------------------------------------------------------
/**
 * @brief   エンカウントポケモンをコースデータに格納
 *
 * @param   poke		PHCポケモン基本データ(phc_struct.h)
 * @param   index
 *
 * @retval  none
 */
//------------------------------------------------------------------
//----------------------------------------------------------------------------------
/**
 * @brief	エンカウントポケモンをコースデータに格納
 *
 * @param   poke			PHCポケモン基本データ(phc_struct.h)
 * @param   walkStep[]		歩数を格納する配列
 * @param   encountRate[]	エンカウント率を格納する配列
 * @param   index			指定のPHCコース
 * @param   select[]		選択されたポケモンを格納する配列
 */
//----------------------------------------------------------------------------------
static void EnemyPokemonSet( PHCPokemonBase *poke, u16 walkStep[], u8 encountRate[], int index, u8 select[] )
{
	const PHC_COURSE_DATA *course = &PhcCourseData[index];
	int i,j,sel;
	int type1, type2;

	// 乱数初期化
	gf_srand(GF_RTC_GetTimeBySecond());

	// 6匹のうち3匹を選び情報をセットする
	// （[0,1][2,3][4,5]のペアのどちらかを選ぶ）
	for(i=0;i<3;i++){
		POKEMON_PERSONAL_DATA *ppd;
		const PHC_ENEMY_POKEMON *pep;
		sel = i*2+gf_rand()%2;	// 2匹の候補のどちらにするか？
		pep = &course->poke[sel];
		select[i] = sel;

		ppd = PokeFormNoPersonalPara_Open(  pep->monsno, pep->form, HEAPID_PHC_LINK );
		poke[i].id       = pep->monsno;
		poke[i].item     = pep->item;
		for(j=0;j<4;j++){
			poke[i].skill[j] = pep->waza[j];
		}
		poke[i].level = pep->level;
		poke[i].folm  = pep->form;
		poke[i].sex   = pep->sex;
		poke[i].isEgg = 0;
		poke[i].reverseFlag = PokePersonalPara_Get( ppd, ID_PER_reverse );

		walkStep[i]    = pep->need_step;
		encountRate[i] = pep->odds;

		PokePersonalPara_Close( ppd );
	}
}


//----------------------------------------------------------------------------------
/**
 * @brief	預けるポケモンの属性がコースの有利属性だった場合はエンカウント率を下げる?
 *
 * @param   advantage[]		有利ポケモン属性の配列
 * @param   ppp		        POKEMON_PASO_PARAM
 * @param   walkStep[]		変更を掛ける必要歩数が入った配列
 */
//----------------------------------------------------------------------------------
static void TypeCheckEncount( const u8 advantage[], POKEMON_PASO_PARAM *ppp, u16 walkStep[] )
{
	// 属性取得
	int type1 = PokePasoParaGet( ppp, ID_PARA_type1, NULL );
	int type2 = PokePasoParaGet( ppp, ID_PARA_type2, NULL );
	int i,flag=0;

	for(i=0;i<3;i++){
		if(type1==advantage[i] || type2==advantage[i]){
			flag=1;
		}
	}

	if(flag){
		for(i=0;i<3;i++){
			int work = (int)(walkStep[i]*75)/100;
			walkStep[i] = work;
		}
	}
}



#define GRA_BMPWIN_NUM	( NELEMS(name_w_tbl) )	///< PHC用に作成するBMPの数

static const pokemon_tbl[5]={01,1,2,3,4};
/******************************************************************************
コースの画像以外のパラメータをセット
******************************************************************************/
static void set_course( PHCCourseData *pCourse, PHCLINK_WORK *wk )
{
	int i;
	u8 map_idx = wk->phcsel.course;
	u8 *p, *buf, poke_select[3];
	GF_BGL_BMPWIN bmpwin[GRA_BMPWIN_NUM];
	buf = sys_AllocMemory( HEAPID_PHC_LINK,PHC_STRING_BUF );


	// 文字描画領域確保
	for(i=0;i<GRA_BMPWIN_NUM;i++){
		  GF_BGL_BmpWinAdd(	wk->bgl, &bmpwin[i], GF_BGL_FRAME1_M,	0, 0, name_w_tbl[i], 2, 0, 0 );
		  GF_BGL_BmpWinDataFill( &bmpwin[i],0 );
	}

	OS_Printf("GRA_BMPWIN_NUM = %d\n", GRA_BMPWIN_NUM);


	/****************************************************************************
	自分が預けるポケモンのパラメータ
	****************************************************************************/
	pCourse->v.pokemon.id = (u16)wk->phcsel.monsno;

	// PokePaso高速モードON
	PokePasoParaFastModeOn(wk->ppp);
	// 技代入
	for(i=0;i<4;i++){
		pCourse->v.pokemon.skill[i] = PokePasoParaGet( wk->ppp, ID_PARA_waza1+i, NULL );
	}
	// レベル
	pCourse->v.pokemon.level = PokePasoParaGet( wk->ppp, ID_PARA_level, NULL );
	// フォルム
	pCourse->v.pokemon.folm  = PokePasoParaGet( wk->ppp, ID_PARA_form_no, NULL );
	// タマゴフラグは絶対に立たない
	pCourse->v.pokemon.isEgg = 0;

	// レアカラーフラグ
	pCourse->v.pokemon.rareColor = PokePasoRareGet(wk->ppp);

	// なつき度
	pCourse->v.friendly      = PokePasoParaGet( wk->ppp, ID_PARA_friend, NULL );


	// ニックネーム
	PokePasoParaGet( wk->ppp, ID_PARA_nickname, pCourse->v.nickname );

	// PokePaso高速モードOFF
	PokePasoParaFastModeOff(wk->ppp, TRUE);

	{
		POKEMON_PERSONAL_DATA *ppd = PokePersonalPara_Open( pCourse->v.pokemon.id, HEAPID_PHC_LINK );
		// 反転フラグ
		pCourse->v.pokemon.reverseFlag = PokePersonalPara_Get( ppd, ID_PER_reverse );
		PokePersonalPara_Close(ppd);
	}
	// 性別
	pCourse->v.pokemon.sex = PokePasoSexGet( wk->ppp );

	/****************************************************************************
		コースデータ代入
	****************************************************************************/


	// コースの背景IDをセット
	pCourse->v.courseId = PhcCourseData[map_idx].graphic_id-1;

	// コース名の格納
	{
		STRBUF *coursename = MSGMAN_AllocString( wk->msg_man, phc_course_name01+wk->phcsel.course );
		STRBUF_GetStringCode( coursename, (STRCODE*)pCourse->v.courseNameString,  (PHC_COURSE_NAME_SIZE+PHC_EOF_SIZE)/2 );
		STRBUF_Delete(coursename);
	}

	// エンカウントポケモン設定
	EnemyPokemonSet( pCourse->v.Enemy, pCourse->v.walkStep, pCourse->v.encountRate, map_idx, poke_select );

	// 預けるポケモンの属性でエンカウント率が下がる処理
	TypeCheckEncount( PhcCourseData[map_idx].advantage, wk->ppp, pCourse->v.walkStep );

	// BMPWINで文字列を画像描画する
	_set_bmpwin_buf( bmpwin, wk, &PhcCourseData[map_idx], poke_select );

	// エンカウントポケモン3匹のアイコン画像をセット
	for(i=0;i<3;i++){
		int iconid = _get_phcicon_index_monsno(pCourse->v.Enemy[i].id);
		p = ArcUtil_Load( ARC_PHC_ICON_GRA, iconid, 1, HEAPID_PHC_LINK, ALLOC_BOTTOM);
		MI_CpuCopy8( p, &(pCourse->imageEnemy[(768/2)*i]), 768/2);
		sys_FreeMemoryEz(p);
	}

	// 3匹目のポケモン正面絵

	p = ArcUtil_Load( ARC_PHC_BIG_GRA,
					  PhcLink_GraArcDataGet( pCourse->v.Enemy[2].id, pCourse->v.Enemy[2].sex, 0 ),
					  1, HEAPID_PHC_LINK, ALLOC_BOTTOM);
	MI_CpuCopy8( p, pCourse->imageEnemyBig, 1536 );
	sys_FreeMemoryEz(p);


	// エンカウントポケモン3匹の名前画像を生成・格納
	for(i=0;i<3;i++){

		bmp2phc( bmpwin[BMP_POKE_NAME0+i].chrbuf, 10, 2, buf, 0, 0, 80, 16 );
		MI_CpuCopy8( buf, &pCourse->enemyName[320*i], 320); // コース出現ポケモン名画像データ
	}

	// アイテム取得確率をセット
	for(i=0;i<CROUSE_ITEM_NUM;i++){ // アイテム取得確率
		pCourse->v.itemNumber[i] = PhcCourseData[map_idx].item[i].no;
		pCourse->v.itemStep[i]   = PhcCourseData[map_idx].item[i].need_step;
		pCourse->v.itemRate[i]   = PhcCourseData[map_idx].item[i].odds;
	}

	/****************************************************************************
	画像のセット
	****************************************************************************/

	// コース背景画像データ
	MI_CpuCopy8( course_graphic_tbl[PhcCourseData[map_idx].graphic_id-1], &pCourse->course[0], 192);

	// コース名画像データセット
	bmp2phc( bmpwin[BMP_COURSE_NAME].chrbuf, 10, 2, buf, 0, 0, 80, 16 );
	MI_CpuCopy8( buf, &pCourse->courseName[320*0], 320);



	// ポケモン画像のセッティング

	// 自分ポケモンアイコン
	{
		int iconid = _get_phcicon_index_ppp( wk->ppp );
		p = ArcUtil_Load( ARC_PHC_ICON_GRA, iconid, 1, HEAPID_PHC_LINK, ALLOC_BOTTOM);
		MI_CpuCopy8( p, pCourse->imagePoke, 768/2);
		sys_FreeMemoryEz(p);
	}
	GF_ASSERT( wk->phcsel.monsno!=0 );

	// ポケモン正面絵

	OS_Printf("monsno=%d, sex=%d, form=%d\n",wk->phcsel.monsno, wk->phcsel.sex, wk->phcsel.form);
	p = ArcUtil_Load( ARC_PHC_BIG_GRA,
					  PhcLink_GraArcDataGet( wk->phcsel.monsno, wk->phcsel.sex, wk->phcsel.form ),
					  1, HEAPID_PHC_LINK, ALLOC_BOTTOM);
	if(wk->phcsel.monsno==MONSNO_PATTIIRU){
		MakePattiiruBuchi( p, (unsigned char*)pmdp_327_buchi_64x48,
							PokePasoParaGet(wk->ppp, ID_PARA_personal_rnd,NULL) );
	}
	MI_CpuCopy8( p, pCourse->imagePokeBig, 1536 );
	sys_FreeMemoryEz(p);

	// ポケモン名グラフィック画像のセッティング
	bmp2phc( bmpwin[BMP_MYPOKE_NAME].chrbuf, 10, 2, buf, 0, 0, 80, 16 );
	MI_CpuCopy8( buf, pCourse->pokeName, 320);

	// アイテム名画像データ
	for(i=0;i<10;i++){
		bmp2phc( bmpwin[BMP_ITEM_NAME0+i].chrbuf, 12, 2, buf, 0, 0, 96, 16 );
		MI_CpuCopy8( buf, &pCourse->item[384*i], 384);

	}

	// 文字列画像BMPWIN全解放
	for(i=0;i<GRA_BMPWIN_NUM;i++){
		GF_BGL_BmpWinDel( &bmpwin[i] );
	}

	sys_FreeMemoryEz(buf);
}

#define PHC_FONT_COLOR	GF_PRINTCOLOR_MAKE( 3, 1, 0 )	///< PHC作成用のカラー指定

#define PHC_GET_ITEM_MAX	( 10 )	///< PHC書き込みどうぐ名最大
#define PHC_GET_POKE_MAX	(  3 )	///< PHC書き込みポケモン名最大

/// PHCに書き出す画像テキストの描画開始位置
#define PHC_TEXT_X	(  2 )


//------------------------------------------------------------------
/**
 * @brief   自分の名前をBMPWINに描画
 *
 * @param   bmpwin	書き込むBMPWIN
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void _set_bmpwin_myname( GF_BGL_BMPWIN *bmpwin, PHCLINK_WORK *wk )
{
	MYSTATUS *mystatus = SaveData_GetMyStatus( wk->savedata );
	STRBUF *myname     = MyStatus_CreateNameString( mystatus, HEAPID_PHC_LINK );

	// 自分の名前描画
	GF_STR_PrintColor( bmpwin, FONT_SYSTEM, myname, PHC_TEXT_X, 0, MSG_NO_PUT, PHC_FONT_COLOR, NULL );
	STRBUF_Delete(myname);

}


//------------------------------------------------------------------
/**
 * @brief   BMPWINで文字列を画像描画する
 *
 * @param   bmpwin	書き込むBMPWIN
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void  _set_bmpwin_buf( GF_BGL_BMPWIN *bmpwin, PHCLINK_WORK *wk, const PHC_COURSE_DATA *course, u8 select[] )
{
	MSGDATA_MANAGER *monsman = MSGMAN_Create( MSGMAN_TYPE_DIRECT, ARC_MSG, NARC_msg_monsname_dat, HEAPID_PHC_LINK );
	STRBUF *itemname,*pokename, *coursename;
	int i,j;

	// 取得できるどうぐ名格納
	for(i=0;i<PHC_GET_ITEM_MAX;i++){
		OS_Printf("itemno = %d\n",course->item[i].no );
		itemname = MSGMAN_AllocString( wk->item_man, course->item[i].no );
		// どうぐ名描画

		for(j=0;j<10;j++){
			u16 *ss = (u16*)itemname;
			OS_Printf("%04x ", ss[j+4]);
		}
		OS_Printf("\n");

		GF_STR_PrintColor( &bmpwin[BMP_ITEM_NAME0+i], FONT_SYSTEM, itemname, PHC_TEXT_X, 1,
							MSG_NO_PUT, PHC_FONT_COLOR, NULL );
		STRBUF_Delete(itemname);
	}

	// エンカウントポケモン名描画
	for(i=0;i<PHC_GET_POKE_MAX;i++){
		pokename = MSGMAN_AllocString( monsman, course->poke[select[i]].monsno );
		// ポケモン名描画
		GF_STR_PrintColor( &bmpwin[BMP_POKE_NAME0+i], FONT_SYSTEM, pokename, PHC_TEXT_X,
							 1, MSG_NO_PUT, PHC_FONT_COLOR, NULL );
		STRBUF_Delete(pokename);

	}

	// コース名描画
	coursename = MSGMAN_AllocString( wk->msg_man, phc_course_name01+wk->phcsel.course );
	GF_STR_PrintColor( &bmpwin[BMP_COURSE_NAME], FONT_SYSTEM, coursename, PHC_TEXT_X,
						0, MSG_NO_PUT, PHC_FONT_COLOR, NULL );
	STRBUF_Delete(coursename);

	// 送信するポケモンの名前を描画(ウムラウト文字対策に１ドット下げてます）
	pokename = STRBUF_Create( BUFLEN_POKEMON_NAME, HEAPID_PHC_LINK );
	PokePasoParaGet( wk->ppp, ID_PARA_nickname_buf, pokename );
	GF_STR_PrintColor( &bmpwin[BMP_MYPOKE_NAME], FONT_SYSTEM, pokename, PHC_TEXT_X, 1,
						MSG_NO_PUT, PHC_FONT_COLOR, NULL );
	STRBUF_Delete(pokename);

	// ポケモン名メッセージマネージャー解放
	MSGMAN_Delete( monsman );
}


#define 	POKEGRA_MAIN_VRAM_OFFSET ( (26*3+14)*0x20 )		///< ポケモンの正面絵を書き込むMAIN-VRAM位置
#define 	POKEGRA_SUB_VRAM_OFFSET  ( (11*8+10)*0x20 )		///< ポケモンの正面絵を書き込むSUB-VRAM位置

//=============================================================================================
/**
 * @brief	 ポケモン正面絵を転送する
 *
 * @param   ppp			POKEMON_PASO_PARAM
 * @param   char_work	展開用メモリワーク
 * @param   ssa			画像取得用のワーク
 * @param   flag		MAINとSUBのどっちか(0:MAIN 1:SUB)
 *
 * @retval  none
 */
//=============================================================================================
int PhcLink_TransPokeGra( POKEMON_PASO_PARAM *ppp, u8 *char_work, SOFT_SPRITE_ARC *ssa, int flag )
{
	// ポケモンの画像を読み込む（ただしソフトウェアスプライト用のテクスチャ状態）
//	PokeGraArcDataGetPP( ssa, pp, PARA_FRONT);
	PokeGraArcDataGetPPP( ssa, ppp, PARA_FRONT, 0);

	// テクスチャをOAM用の並びに変換する
	{
		int rnd    = PokePasoParaGet( ppp, ID_PARA_personal_rnd, NULL );
		int monsno = PokePasoParaGet( ppp, ID_PARA_monsno, NULL );
		Ex_ChangesInto_OAM_from_PokeTex(ssa->arc_no, ssa->index_chr, HEAPID_PHC_LINK, 0, 0, 10, 10, char_work,
										rnd, 0, PARA_FRONT, monsno);
	}

	DC_FlushRange( char_work, POKEGRA_SIZE );	// 転送前にメモリ安定


	if(flag==0){
		// OAM用MAIN-VRAMに転送
		GX_LoadOBJ( char_work, POKEGRA_MAIN_VRAM_OFFSET , POKEGRA_SIZE);

		// パレット転送
		ArcUtil_PalSet( ssa->arc_no, ssa->index_pal,
					PALTYPE_MAIN_OBJ, 0x20*4, 32, HEAPID_PHC_LINK );
	}else{
		// OAM用SUB-VRAMに転送
		GXS_LoadOBJ( char_work, POKEGRA_SUB_VRAM_OFFSET , POKEGRA_SIZE);

		// パレット転送
		ArcUtil_PalSet( ssa->arc_no, ssa->index_pal,
					PALTYPE_SUB_OBJ, 0x20*1, 32, HEAPID_PHC_LINK );
	}


	return 0;


}


//==============================================================================
/**
 * @brief   DS内で認識しているPHC処理の状態
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  int		PHCLINK_NO_INI=0,			// PHCを初期化した事がない
 *					PHCLINK_ALREADY_ENTRY,		// 初期化してあってPHCに預けてある
 *					PHCLINK_ALREADY_NO_ENTRY,	// 初期化してあってPHCに預けてはいない
 *
 */
//==============================================================================
int PhcLink_GetPhcMode( PHCLINK_WORK *wk)
{
	u16 flag, box;

	PhcSvData_GetDepositInfo( wk->phc_svdata, &flag, &box );

	// セーブデータで分岐させる
	if(flag==0){
		// 初期化してない
		return PHCLINK_NO_INIT;
	}

	// PHCに預けてる
	return PHCLINK_ALREADY_ENTRY;
}



#define ONE_CELL_SIZE	( 32 )		///< ポケモンアイコンのキャラサイズ


//------------------------------------------------------------------
/**
 * @brief   データからピクセルデータを読み込むサブ
 *
 * @param   data	ピクセルデータ
 * @param   w		元画像の横幅
 * @param   x		画像内のX座標
 * @param   y		画像内のY座標
 *
 * @retval  int		読み込んだピクセル情報(0-15)
 */
//------------------------------------------------------------------
static int get_pixel_sub( u8 *data, int w, int x, int y )
{
	int cpos = (x/8) + (y/8)*w;
	int ipos = (x%8)+(y%8)*8;
	int pixel = 0;


	if((ipos&1)==1){
		pixel = data[ipos/2+cpos*ONE_CELL_SIZE]>>4;
	}else{
		pixel = data[ipos/2+cpos*ONE_CELL_SIZE]&0xf;
	}

	return pixel;

}

//----------------------------------------------------------------------------------
/**
 * @brief	NCGをPHC配列に変換
 *
 * @param   bmp		NCGフォーマットのキャラクター配列
 * @param   in_w	元画像の横幅
 * @param   in_h	元画像の縦幅
 * @param   phc		PHCフォーマットに変換して書き込む配列
 * @param   x		開始X座標
 * @param   y		開始Y座標
 * @param   w		横幅
 * @param   h		縦幅
 *
 * @retval  int		書き込んだピクセル数
 */
//----------------------------------------------------------------------------------
static int bmp2phc( u8 *bmp, int in_w, int in_h, u8 *phc, int x, int y, int w, int h )
{
	int wx,wy,n,count=0;
	int pixel;

	// 出力領域のクリア
	MI_CpuClearFast( phc, w*h/8*2 );

	// NCGデータをPHCフォーマットに変換
	for(n=0;n<(h/8);n++){
		for(wx=0;wx<w;wx++){
			for(wy=0;wy<8;wy++){
				pixel = get_pixel_sub( bmp, in_w, wx+x, y+wy+n*8);
				phc[count]   |= (pixel>>1)<<wy;
				phc[count+1] |= (pixel &1)<<wy;
			}
			count+=2;
		}
	}

	return count;
}


///< pokeicon.naixとphcicon.naixの先頭の差
#define PHCICON_INDEX_SUB	( 7 )

//------------------------------------------------------------------
/**
 * @brief   PHCICONのアーカイブインデックスを取得する(PPP版)
 *			この関数はphc_icon.naixがicongra/poke_icon.naix
 *			と同じ並びでアーカイブされている事を利用して作成されている。
 *			pokeicon.hのアーカイブ取得関数でpokeicon用のインデックスを
 *			取得したあと、phcicon.naixには入れていない先頭のデータを
 *			削って取得している。
 *			フォルムチェンジにも対応。（ギラティナ・シェイミ・ロトム）
 *			ギザ耳ピチューは未定
 *
 * @param   POKEMON_PASO_PARAM
 *
 * @retval  int		アーカイブインデックス
 */
//------------------------------------------------------------------
static int _get_phcicon_index_ppp( POKEMON_PASO_PARAM *ppp )
{
	// pokeicon.hで取得したアーカイブ番号-７がphcicon用の番号
	return PokeIconCgxArcIndexGet(ppp) - PHCICON_INDEX_SUB;
}

//------------------------------------------------------------------
/**
 * @brief   PHCICONのアーカイブインデックスを取得する(開発NO版)
 *			この関数はphc_icon.naixがicongra/poke_icon.naix
 *			と同じ並びでアーカイブされている事を利用して作成されている。
 *			pokeicon.hのアーカイブ取得関数でpokeicon用のインデックスを
 *			取得したあと、phcicon.naixには入れていない先頭のデータを
 *			削って取得している。
 *			フォルムチェンジにも対応。（ギラティナ・シェイミ・ロトム）
 *			ギザ耳ピチューは未定
 *
 * @param   mons	ポケモンNO
 *
 * @retval  int		アーカイブインデックス
 */
//------------------------------------------------------------------
static int _get_phcicon_index_monsno( int mons )
{
	return PokeIconCgxArcIndexGetByMonsNumber( mons, 0, 0 )-PHCICON_INDEX_SUB;
}


//==============================================================================
/**
 * @brief   ぶち取得（未使用）
 *
 * @param   gra
 * @param[in]	rnd		生成するための個性乱数（パッチール）
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_GraMakeBuchi( u8 *gra, const int monsno, const int rnd  )
{

}

// 性別に対応した正面絵アーカイブを取得するためのテーブル
const static u16 pokegra_sex_table[][2]={
	{ NARC_phcgra_pmdp_001_m_lz_dat, NARC_phcgra_pmdp_001_m_lz_dat, },
	{ NARC_phcgra_pmdp_001_m_lz_dat, NARC_phcgra_pmdp_001_m_lz_dat, },
	{ NARC_phcgra_pmdp_002_m_lz_dat, NARC_phcgra_pmdp_002_m_lz_dat, },
	{ NARC_phcgra_pmdp_003_m_lz_dat, NARC_phcgra_pmdp_003_f_lz_dat, },
	{ NARC_phcgra_pmdp_004_m_lz_dat, NARC_phcgra_pmdp_004_m_lz_dat, },
	{ NARC_phcgra_pmdp_005_m_lz_dat, NARC_phcgra_pmdp_005_m_lz_dat, },
	{ NARC_phcgra_pmdp_006_m_lz_dat, NARC_phcgra_pmdp_006_m_lz_dat, },
	{ NARC_phcgra_pmdp_007_m_lz_dat, NARC_phcgra_pmdp_007_m_lz_dat, },
	{ NARC_phcgra_pmdp_008_m_lz_dat, NARC_phcgra_pmdp_008_m_lz_dat, },
	{ NARC_phcgra_pmdp_009_m_lz_dat, NARC_phcgra_pmdp_009_m_lz_dat, },
	{ NARC_phcgra_pmdp_010_m_lz_dat, NARC_phcgra_pmdp_010_m_lz_dat, },
	{ NARC_phcgra_pmdp_011_m_lz_dat, NARC_phcgra_pmdp_011_m_lz_dat, },
	{ NARC_phcgra_pmdp_012_m_lz_dat, NARC_phcgra_pmdp_012_f_lz_dat, },
	{ NARC_phcgra_pmdp_013_m_lz_dat, NARC_phcgra_pmdp_013_m_lz_dat, },
	{ NARC_phcgra_pmdp_014_m_lz_dat, NARC_phcgra_pmdp_014_m_lz_dat, },
	{ NARC_phcgra_pmdp_015_m_lz_dat, NARC_phcgra_pmdp_015_m_lz_dat, },
	{ NARC_phcgra_pmdp_016_m_lz_dat, NARC_phcgra_pmdp_016_m_lz_dat, },
	{ NARC_phcgra_pmdp_017_m_lz_dat, NARC_phcgra_pmdp_017_m_lz_dat, },
	{ NARC_phcgra_pmdp_018_m_lz_dat, NARC_phcgra_pmdp_018_m_lz_dat, },
	{ NARC_phcgra_pmdp_019_m_lz_dat, NARC_phcgra_pmdp_019_f_lz_dat, },
	{ NARC_phcgra_pmdp_020_m_lz_dat, NARC_phcgra_pmdp_020_f_lz_dat, },
	{ NARC_phcgra_pmdp_021_m_lz_dat, NARC_phcgra_pmdp_021_m_lz_dat, },
	{ NARC_phcgra_pmdp_022_m_lz_dat, NARC_phcgra_pmdp_022_m_lz_dat, },
	{ NARC_phcgra_pmdp_023_m_lz_dat, NARC_phcgra_pmdp_023_m_lz_dat, },
	{ NARC_phcgra_pmdp_024_m_lz_dat, NARC_phcgra_pmdp_024_m_lz_dat, },
	{ NARC_phcgra_pmdp_025_m_lz_dat, NARC_phcgra_pmdp_025_f_lz_dat, },
	{ NARC_phcgra_pmdp_026_m_lz_dat, NARC_phcgra_pmdp_026_f_lz_dat, },
	{ NARC_phcgra_pmdp_027_m_lz_dat, NARC_phcgra_pmdp_027_m_lz_dat, },
	{ NARC_phcgra_pmdp_028_m_lz_dat, NARC_phcgra_pmdp_028_m_lz_dat, },
	{ NARC_phcgra_pmdp_029_m_lz_dat, NARC_phcgra_pmdp_029_m_lz_dat, },
	{ NARC_phcgra_pmdp_030_m_lz_dat, NARC_phcgra_pmdp_030_m_lz_dat, },
	{ NARC_phcgra_pmdp_031_m_lz_dat, NARC_phcgra_pmdp_031_m_lz_dat, },
	{ NARC_phcgra_pmdp_032_m_lz_dat, NARC_phcgra_pmdp_032_m_lz_dat, },
	{ NARC_phcgra_pmdp_033_m_lz_dat, NARC_phcgra_pmdp_033_m_lz_dat, },
	{ NARC_phcgra_pmdp_034_m_lz_dat, NARC_phcgra_pmdp_034_m_lz_dat, },
	{ NARC_phcgra_pmdp_035_m_lz_dat, NARC_phcgra_pmdp_035_m_lz_dat, },
	{ NARC_phcgra_pmdp_036_m_lz_dat, NARC_phcgra_pmdp_036_m_lz_dat, },
	{ NARC_phcgra_pmdp_037_m_lz_dat, NARC_phcgra_pmdp_037_m_lz_dat, },
	{ NARC_phcgra_pmdp_038_m_lz_dat, NARC_phcgra_pmdp_038_m_lz_dat, },
	{ NARC_phcgra_pmdp_039_m_lz_dat, NARC_phcgra_pmdp_039_m_lz_dat, },
	{ NARC_phcgra_pmdp_040_m_lz_dat, NARC_phcgra_pmdp_040_m_lz_dat, },
	{ NARC_phcgra_pmdp_041_m_lz_dat, NARC_phcgra_pmdp_041_f_lz_dat, },
	{ NARC_phcgra_pmdp_042_m_lz_dat, NARC_phcgra_pmdp_042_f_lz_dat, },
	{ NARC_phcgra_pmdp_043_m_lz_dat, NARC_phcgra_pmdp_043_m_lz_dat, },
	{ NARC_phcgra_pmdp_044_m_lz_dat, NARC_phcgra_pmdp_044_f_lz_dat, },
	{ NARC_phcgra_pmdp_045_m_lz_dat, NARC_phcgra_pmdp_045_f_lz_dat, },
	{ NARC_phcgra_pmdp_046_m_lz_dat, NARC_phcgra_pmdp_046_m_lz_dat, },
	{ NARC_phcgra_pmdp_047_m_lz_dat, NARC_phcgra_pmdp_047_m_lz_dat, },
	{ NARC_phcgra_pmdp_048_m_lz_dat, NARC_phcgra_pmdp_048_m_lz_dat, },
	{ NARC_phcgra_pmdp_049_m_lz_dat, NARC_phcgra_pmdp_049_m_lz_dat, },
	{ NARC_phcgra_pmdp_050_m_lz_dat, NARC_phcgra_pmdp_050_m_lz_dat, },
	{ NARC_phcgra_pmdp_051_m_lz_dat, NARC_phcgra_pmdp_051_m_lz_dat, },
	{ NARC_phcgra_pmdp_052_m_lz_dat, NARC_phcgra_pmdp_052_m_lz_dat, },
	{ NARC_phcgra_pmdp_053_m_lz_dat, NARC_phcgra_pmdp_053_m_lz_dat, },
	{ NARC_phcgra_pmdp_054_m_lz_dat, NARC_phcgra_pmdp_054_m_lz_dat, },
	{ NARC_phcgra_pmdp_055_m_lz_dat, NARC_phcgra_pmdp_055_m_lz_dat, },
	{ NARC_phcgra_pmdp_056_m_lz_dat, NARC_phcgra_pmdp_056_m_lz_dat, },
	{ NARC_phcgra_pmdp_057_m_lz_dat, NARC_phcgra_pmdp_057_m_lz_dat, },
	{ NARC_phcgra_pmdp_058_m_lz_dat, NARC_phcgra_pmdp_058_m_lz_dat, },
	{ NARC_phcgra_pmdp_059_m_lz_dat, NARC_phcgra_pmdp_059_m_lz_dat, },
	{ NARC_phcgra_pmdp_060_m_lz_dat, NARC_phcgra_pmdp_060_m_lz_dat, },
	{ NARC_phcgra_pmdp_061_m_lz_dat, NARC_phcgra_pmdp_061_m_lz_dat, },
	{ NARC_phcgra_pmdp_062_m_lz_dat, NARC_phcgra_pmdp_062_m_lz_dat, },
	{ NARC_phcgra_pmdp_063_m_lz_dat, NARC_phcgra_pmdp_063_m_lz_dat, },
	{ NARC_phcgra_pmdp_064_m_lz_dat, NARC_phcgra_pmdp_064_f_lz_dat, },
	{ NARC_phcgra_pmdp_065_m_lz_dat, NARC_phcgra_pmdp_065_f_lz_dat, },
	{ NARC_phcgra_pmdp_066_m_lz_dat, NARC_phcgra_pmdp_066_m_lz_dat, },
	{ NARC_phcgra_pmdp_067_m_lz_dat, NARC_phcgra_pmdp_067_m_lz_dat, },
	{ NARC_phcgra_pmdp_068_m_lz_dat, NARC_phcgra_pmdp_068_m_lz_dat, },
	{ NARC_phcgra_pmdp_069_m_lz_dat, NARC_phcgra_pmdp_069_m_lz_dat, },
	{ NARC_phcgra_pmdp_070_m_lz_dat, NARC_phcgra_pmdp_070_m_lz_dat, },
	{ NARC_phcgra_pmdp_071_m_lz_dat, NARC_phcgra_pmdp_071_m_lz_dat, },
	{ NARC_phcgra_pmdp_072_m_lz_dat, NARC_phcgra_pmdp_072_m_lz_dat, },
	{ NARC_phcgra_pmdp_073_m_lz_dat, NARC_phcgra_pmdp_073_m_lz_dat, },
	{ NARC_phcgra_pmdp_074_m_lz_dat, NARC_phcgra_pmdp_074_m_lz_dat, },
	{ NARC_phcgra_pmdp_075_m_lz_dat, NARC_phcgra_pmdp_075_m_lz_dat, },
	{ NARC_phcgra_pmdp_076_m_lz_dat, NARC_phcgra_pmdp_076_m_lz_dat, },
	{ NARC_phcgra_pmdp_077_m_lz_dat, NARC_phcgra_pmdp_077_m_lz_dat, },
	{ NARC_phcgra_pmdp_078_m_lz_dat, NARC_phcgra_pmdp_078_m_lz_dat, },
	{ NARC_phcgra_pmdp_079_m_lz_dat, NARC_phcgra_pmdp_079_m_lz_dat, },
	{ NARC_phcgra_pmdp_080_m_lz_dat, NARC_phcgra_pmdp_080_m_lz_dat, },
	{ NARC_phcgra_pmdp_081_m_lz_dat, NARC_phcgra_pmdp_081_m_lz_dat, },
	{ NARC_phcgra_pmdp_082_m_lz_dat, NARC_phcgra_pmdp_082_m_lz_dat, },
	{ NARC_phcgra_pmdp_083_m_lz_dat, NARC_phcgra_pmdp_083_m_lz_dat, },
	{ NARC_phcgra_pmdp_084_m_lz_dat, NARC_phcgra_pmdp_084_f_lz_dat, },
	{ NARC_phcgra_pmdp_085_m_lz_dat, NARC_phcgra_pmdp_085_f_lz_dat, },
	{ NARC_phcgra_pmdp_086_m_lz_dat, NARC_phcgra_pmdp_086_m_lz_dat, },
	{ NARC_phcgra_pmdp_087_m_lz_dat, NARC_phcgra_pmdp_087_m_lz_dat, },
	{ NARC_phcgra_pmdp_088_m_lz_dat, NARC_phcgra_pmdp_088_m_lz_dat, },
	{ NARC_phcgra_pmdp_089_m_lz_dat, NARC_phcgra_pmdp_089_m_lz_dat, },
	{ NARC_phcgra_pmdp_090_m_lz_dat, NARC_phcgra_pmdp_090_m_lz_dat, },
	{ NARC_phcgra_pmdp_091_m_lz_dat, NARC_phcgra_pmdp_091_m_lz_dat, },
	{ NARC_phcgra_pmdp_092_m_lz_dat, NARC_phcgra_pmdp_092_m_lz_dat, },
	{ NARC_phcgra_pmdp_093_m_lz_dat, NARC_phcgra_pmdp_093_m_lz_dat, },
	{ NARC_phcgra_pmdp_094_m_lz_dat, NARC_phcgra_pmdp_094_m_lz_dat, },
	{ NARC_phcgra_pmdp_095_m_lz_dat, NARC_phcgra_pmdp_095_m_lz_dat, },
	{ NARC_phcgra_pmdp_096_m_lz_dat, NARC_phcgra_pmdp_096_m_lz_dat, },
	{ NARC_phcgra_pmdp_097_m_lz_dat, NARC_phcgra_pmdp_097_f_lz_dat, },
	{ NARC_phcgra_pmdp_098_m_lz_dat, NARC_phcgra_pmdp_098_m_lz_dat, },
	{ NARC_phcgra_pmdp_099_m_lz_dat, NARC_phcgra_pmdp_099_m_lz_dat, },
	{ NARC_phcgra_pmdp_100_m_lz_dat, NARC_phcgra_pmdp_100_m_lz_dat, },
	{ NARC_phcgra_pmdp_101_m_lz_dat, NARC_phcgra_pmdp_101_m_lz_dat, },
	{ NARC_phcgra_pmdp_102_m_lz_dat, NARC_phcgra_pmdp_102_m_lz_dat, },
	{ NARC_phcgra_pmdp_103_m_lz_dat, NARC_phcgra_pmdp_103_m_lz_dat, },
	{ NARC_phcgra_pmdp_104_m_lz_dat, NARC_phcgra_pmdp_104_m_lz_dat, },
	{ NARC_phcgra_pmdp_105_m_lz_dat, NARC_phcgra_pmdp_105_m_lz_dat, },
	{ NARC_phcgra_pmdp_106_m_lz_dat, NARC_phcgra_pmdp_106_m_lz_dat, },
	{ NARC_phcgra_pmdp_107_m_lz_dat, NARC_phcgra_pmdp_107_m_lz_dat, },
	{ NARC_phcgra_pmdp_108_m_lz_dat, NARC_phcgra_pmdp_108_m_lz_dat, },
	{ NARC_phcgra_pmdp_109_m_lz_dat, NARC_phcgra_pmdp_109_m_lz_dat, },
	{ NARC_phcgra_pmdp_110_m_lz_dat, NARC_phcgra_pmdp_110_m_lz_dat, },
	{ NARC_phcgra_pmdp_111_m_lz_dat, NARC_phcgra_pmdp_111_f_lz_dat, },
	{ NARC_phcgra_pmdp_112_m_lz_dat, NARC_phcgra_pmdp_112_f_lz_dat, },
	{ NARC_phcgra_pmdp_113_m_lz_dat, NARC_phcgra_pmdp_113_m_lz_dat, },
	{ NARC_phcgra_pmdp_114_m_lz_dat, NARC_phcgra_pmdp_114_m_lz_dat, },
	{ NARC_phcgra_pmdp_115_m_lz_dat, NARC_phcgra_pmdp_115_m_lz_dat, },
	{ NARC_phcgra_pmdp_116_m_lz_dat, NARC_phcgra_pmdp_116_m_lz_dat, },
	{ NARC_phcgra_pmdp_117_m_lz_dat, NARC_phcgra_pmdp_117_m_lz_dat, },
	{ NARC_phcgra_pmdp_118_m_lz_dat, NARC_phcgra_pmdp_118_f_lz_dat, },
	{ NARC_phcgra_pmdp_119_m_lz_dat, NARC_phcgra_pmdp_119_f_lz_dat, },
	{ NARC_phcgra_pmdp_120_m_lz_dat, NARC_phcgra_pmdp_120_m_lz_dat, },
	{ NARC_phcgra_pmdp_121_m_lz_dat, NARC_phcgra_pmdp_121_m_lz_dat, },
	{ NARC_phcgra_pmdp_122_m_lz_dat, NARC_phcgra_pmdp_122_m_lz_dat, },
	{ NARC_phcgra_pmdp_123_m_lz_dat, NARC_phcgra_pmdp_123_f_lz_dat, },
	{ NARC_phcgra_pmdp_124_m_lz_dat, NARC_phcgra_pmdp_124_m_lz_dat, },
	{ NARC_phcgra_pmdp_125_m_lz_dat, NARC_phcgra_pmdp_125_m_lz_dat, },
	{ NARC_phcgra_pmdp_126_m_lz_dat, NARC_phcgra_pmdp_126_m_lz_dat, },
	{ NARC_phcgra_pmdp_127_m_lz_dat, NARC_phcgra_pmdp_127_m_lz_dat, },
	{ NARC_phcgra_pmdp_128_m_lz_dat, NARC_phcgra_pmdp_128_m_lz_dat, },
	{ NARC_phcgra_pmdp_129_m_lz_dat, NARC_phcgra_pmdp_129_f_lz_dat, },
	{ NARC_phcgra_pmdp_130_m_lz_dat, NARC_phcgra_pmdp_130_f_lz_dat, },
	{ NARC_phcgra_pmdp_131_m_lz_dat, NARC_phcgra_pmdp_131_m_lz_dat, },
	{ NARC_phcgra_pmdp_132_m_lz_dat, NARC_phcgra_pmdp_132_m_lz_dat, },
	{ NARC_phcgra_pmdp_133_m_lz_dat, NARC_phcgra_pmdp_133_m_lz_dat, },
	{ NARC_phcgra_pmdp_134_m_lz_dat, NARC_phcgra_pmdp_134_m_lz_dat, },
	{ NARC_phcgra_pmdp_135_m_lz_dat, NARC_phcgra_pmdp_135_m_lz_dat, },
	{ NARC_phcgra_pmdp_136_m_lz_dat, NARC_phcgra_pmdp_136_m_lz_dat, },
	{ NARC_phcgra_pmdp_137_m_lz_dat, NARC_phcgra_pmdp_137_m_lz_dat, },
	{ NARC_phcgra_pmdp_138_m_lz_dat, NARC_phcgra_pmdp_138_m_lz_dat, },
	{ NARC_phcgra_pmdp_139_m_lz_dat, NARC_phcgra_pmdp_139_m_lz_dat, },
	{ NARC_phcgra_pmdp_140_m_lz_dat, NARC_phcgra_pmdp_140_m_lz_dat, },
	{ NARC_phcgra_pmdp_141_m_lz_dat, NARC_phcgra_pmdp_141_m_lz_dat, },
	{ NARC_phcgra_pmdp_142_m_lz_dat, NARC_phcgra_pmdp_142_m_lz_dat, },
	{ NARC_phcgra_pmdp_143_m_lz_dat, NARC_phcgra_pmdp_143_m_lz_dat, },
	{ NARC_phcgra_pmdp_144_m_lz_dat, NARC_phcgra_pmdp_144_m_lz_dat, },
	{ NARC_phcgra_pmdp_145_m_lz_dat, NARC_phcgra_pmdp_145_m_lz_dat, },
	{ NARC_phcgra_pmdp_146_m_lz_dat, NARC_phcgra_pmdp_146_m_lz_dat, },
	{ NARC_phcgra_pmdp_147_m_lz_dat, NARC_phcgra_pmdp_147_m_lz_dat, },
	{ NARC_phcgra_pmdp_148_m_lz_dat, NARC_phcgra_pmdp_148_m_lz_dat, },
	{ NARC_phcgra_pmdp_149_m_lz_dat, NARC_phcgra_pmdp_149_m_lz_dat, },
	{ NARC_phcgra_pmdp_150_m_lz_dat, NARC_phcgra_pmdp_150_m_lz_dat, },
	{ NARC_phcgra_pmdp_151_m_lz_dat, NARC_phcgra_pmdp_151_m_lz_dat, },
	{ NARC_phcgra_pmdp_152_m_lz_dat, NARC_phcgra_pmdp_152_m_lz_dat, },
	{ NARC_phcgra_pmdp_153_m_lz_dat, NARC_phcgra_pmdp_153_m_lz_dat, },
	{ NARC_phcgra_pmdp_154_m_lz_dat, NARC_phcgra_pmdp_154_f_lz_dat, },
	{ NARC_phcgra_pmdp_155_m_lz_dat, NARC_phcgra_pmdp_155_m_lz_dat, },
	{ NARC_phcgra_pmdp_156_m_lz_dat, NARC_phcgra_pmdp_156_m_lz_dat, },
	{ NARC_phcgra_pmdp_157_m_lz_dat, NARC_phcgra_pmdp_157_m_lz_dat, },
	{ NARC_phcgra_pmdp_158_m_lz_dat, NARC_phcgra_pmdp_158_m_lz_dat, },
	{ NARC_phcgra_pmdp_159_m_lz_dat, NARC_phcgra_pmdp_159_m_lz_dat, },
	{ NARC_phcgra_pmdp_160_m_lz_dat, NARC_phcgra_pmdp_160_m_lz_dat, },
	{ NARC_phcgra_pmdp_161_m_lz_dat, NARC_phcgra_pmdp_161_m_lz_dat, },
	{ NARC_phcgra_pmdp_162_m_lz_dat, NARC_phcgra_pmdp_162_m_lz_dat, },
	{ NARC_phcgra_pmdp_163_m_lz_dat, NARC_phcgra_pmdp_163_m_lz_dat, },
	{ NARC_phcgra_pmdp_164_m_lz_dat, NARC_phcgra_pmdp_164_m_lz_dat, },
	{ NARC_phcgra_pmdp_165_m_lz_dat, NARC_phcgra_pmdp_165_f_lz_dat, },
	{ NARC_phcgra_pmdp_166_m_lz_dat, NARC_phcgra_pmdp_166_f_lz_dat, },
	{ NARC_phcgra_pmdp_167_m_lz_dat, NARC_phcgra_pmdp_167_m_lz_dat, },
	{ NARC_phcgra_pmdp_168_m_lz_dat, NARC_phcgra_pmdp_168_m_lz_dat, },
	{ NARC_phcgra_pmdp_169_m_lz_dat, NARC_phcgra_pmdp_169_m_lz_dat, },
	{ NARC_phcgra_pmdp_170_m_lz_dat, NARC_phcgra_pmdp_170_m_lz_dat, },
	{ NARC_phcgra_pmdp_171_m_lz_dat, NARC_phcgra_pmdp_171_m_lz_dat, },
	{ NARC_phcgra_pmdp_172_m_lz_dat, NARC_phcgra_pmdp_172_m_lz_dat, },
	{ NARC_phcgra_pmdp_173_m_lz_dat, NARC_phcgra_pmdp_173_m_lz_dat, },
	{ NARC_phcgra_pmdp_174_m_lz_dat, NARC_phcgra_pmdp_174_m_lz_dat, },
	{ NARC_phcgra_pmdp_175_m_lz_dat, NARC_phcgra_pmdp_175_m_lz_dat, },
	{ NARC_phcgra_pmdp_176_m_lz_dat, NARC_phcgra_pmdp_176_m_lz_dat, },
	{ NARC_phcgra_pmdp_177_m_lz_dat, NARC_phcgra_pmdp_177_m_lz_dat, },
	{ NARC_phcgra_pmdp_178_m_lz_dat, NARC_phcgra_pmdp_178_f_lz_dat, },
	{ NARC_phcgra_pmdp_179_m_lz_dat, NARC_phcgra_pmdp_179_m_lz_dat, },
	{ NARC_phcgra_pmdp_180_m_lz_dat, NARC_phcgra_pmdp_180_m_lz_dat, },
	{ NARC_phcgra_pmdp_181_m_lz_dat, NARC_phcgra_pmdp_181_m_lz_dat, },
	{ NARC_phcgra_pmdp_182_m_lz_dat, NARC_phcgra_pmdp_182_m_lz_dat, },
	{ NARC_phcgra_pmdp_183_m_lz_dat, NARC_phcgra_pmdp_183_m_lz_dat, },
	{ NARC_phcgra_pmdp_184_m_lz_dat, NARC_phcgra_pmdp_184_m_lz_dat, },
	{ NARC_phcgra_pmdp_185_m_lz_dat, NARC_phcgra_pmdp_185_f_lz_dat, },
	{ NARC_phcgra_pmdp_186_m_lz_dat, NARC_phcgra_pmdp_186_f_lz_dat, },
	{ NARC_phcgra_pmdp_187_m_lz_dat, NARC_phcgra_pmdp_187_m_lz_dat, },
	{ NARC_phcgra_pmdp_188_m_lz_dat, NARC_phcgra_pmdp_188_m_lz_dat, },
	{ NARC_phcgra_pmdp_189_m_lz_dat, NARC_phcgra_pmdp_189_m_lz_dat, },
	{ NARC_phcgra_pmdp_190_m_lz_dat, NARC_phcgra_pmdp_190_f_lz_dat, },
	{ NARC_phcgra_pmdp_191_m_lz_dat, NARC_phcgra_pmdp_191_m_lz_dat, },
	{ NARC_phcgra_pmdp_192_m_lz_dat, NARC_phcgra_pmdp_192_m_lz_dat, },
	{ NARC_phcgra_pmdp_193_m_lz_dat, NARC_phcgra_pmdp_193_m_lz_dat, },
	{ NARC_phcgra_pmdp_194_m_lz_dat, NARC_phcgra_pmdp_194_f_lz_dat, },
	{ NARC_phcgra_pmdp_195_m_lz_dat, NARC_phcgra_pmdp_195_f_lz_dat, },
	{ NARC_phcgra_pmdp_196_m_lz_dat, NARC_phcgra_pmdp_196_m_lz_dat, },
	{ NARC_phcgra_pmdp_197_m_lz_dat, NARC_phcgra_pmdp_197_m_lz_dat, },
	{ NARC_phcgra_pmdp_198_m_lz_dat, NARC_phcgra_pmdp_198_f_lz_dat, },
	{ NARC_phcgra_pmdp_199_m_lz_dat, NARC_phcgra_pmdp_199_m_lz_dat, },
	{ NARC_phcgra_pmdp_200_m_lz_dat, NARC_phcgra_pmdp_200_m_lz_dat, },
	{ NARC_phcgra_pmdp_201_m_lz_dat, NARC_phcgra_pmdp_201_m_lz_dat, },
	{ NARC_phcgra_pmdp_202_m_lz_dat, NARC_phcgra_pmdp_202_f_lz_dat, },
	{ NARC_phcgra_pmdp_203_m_lz_dat, NARC_phcgra_pmdp_203_f_lz_dat, },
	{ NARC_phcgra_pmdp_204_m_lz_dat, NARC_phcgra_pmdp_204_m_lz_dat, },
	{ NARC_phcgra_pmdp_205_m_lz_dat, NARC_phcgra_pmdp_205_m_lz_dat, },
	{ NARC_phcgra_pmdp_206_m_lz_dat, NARC_phcgra_pmdp_206_m_lz_dat, },
	{ NARC_phcgra_pmdp_207_m_lz_dat, NARC_phcgra_pmdp_207_f_lz_dat, },
	{ NARC_phcgra_pmdp_208_m_lz_dat, NARC_phcgra_pmdp_208_f_lz_dat, },
	{ NARC_phcgra_pmdp_209_m_lz_dat, NARC_phcgra_pmdp_209_m_lz_dat, },
	{ NARC_phcgra_pmdp_210_m_lz_dat, NARC_phcgra_pmdp_210_m_lz_dat, },
	{ NARC_phcgra_pmdp_211_m_lz_dat, NARC_phcgra_pmdp_211_m_lz_dat, },
	{ NARC_phcgra_pmdp_212_m_lz_dat, NARC_phcgra_pmdp_212_f_lz_dat, },
	{ NARC_phcgra_pmdp_213_m_lz_dat, NARC_phcgra_pmdp_213_m_lz_dat, },
	{ NARC_phcgra_pmdp_214_m_lz_dat, NARC_phcgra_pmdp_214_f_lz_dat, },
	{ NARC_phcgra_pmdp_215_m_lz_dat, NARC_phcgra_pmdp_215_f_lz_dat, },
	{ NARC_phcgra_pmdp_216_m_lz_dat, NARC_phcgra_pmdp_216_m_lz_dat, },
	{ NARC_phcgra_pmdp_217_m_lz_dat, NARC_phcgra_pmdp_217_f_lz_dat, },
	{ NARC_phcgra_pmdp_218_m_lz_dat, NARC_phcgra_pmdp_218_m_lz_dat, },
	{ NARC_phcgra_pmdp_219_m_lz_dat, NARC_phcgra_pmdp_219_m_lz_dat, },
	{ NARC_phcgra_pmdp_220_m_lz_dat, NARC_phcgra_pmdp_220_m_lz_dat, },
	{ NARC_phcgra_pmdp_221_m_lz_dat, NARC_phcgra_pmdp_221_f_lz_dat, },
	{ NARC_phcgra_pmdp_222_m_lz_dat, NARC_phcgra_pmdp_222_m_lz_dat, },
	{ NARC_phcgra_pmdp_223_m_lz_dat, NARC_phcgra_pmdp_223_m_lz_dat, },
	{ NARC_phcgra_pmdp_224_m_lz_dat, NARC_phcgra_pmdp_224_f_lz_dat, },
	{ NARC_phcgra_pmdp_225_m_lz_dat, NARC_phcgra_pmdp_225_m_lz_dat, },
	{ NARC_phcgra_pmdp_226_m_lz_dat, NARC_phcgra_pmdp_226_m_lz_dat, },
	{ NARC_phcgra_pmdp_227_m_lz_dat, NARC_phcgra_pmdp_227_m_lz_dat, },
	{ NARC_phcgra_pmdp_228_m_lz_dat, NARC_phcgra_pmdp_228_m_lz_dat, },
	{ NARC_phcgra_pmdp_229_m_lz_dat, NARC_phcgra_pmdp_229_f_lz_dat, },
	{ NARC_phcgra_pmdp_230_m_lz_dat, NARC_phcgra_pmdp_230_m_lz_dat, },
	{ NARC_phcgra_pmdp_231_m_lz_dat, NARC_phcgra_pmdp_231_m_lz_dat, },
	{ NARC_phcgra_pmdp_232_m_lz_dat, NARC_phcgra_pmdp_232_f_lz_dat, },
	{ NARC_phcgra_pmdp_233_m_lz_dat, NARC_phcgra_pmdp_233_m_lz_dat, },
	{ NARC_phcgra_pmdp_234_m_lz_dat, NARC_phcgra_pmdp_234_m_lz_dat, },
	{ NARC_phcgra_pmdp_235_m_lz_dat, NARC_phcgra_pmdp_235_m_lz_dat, },
	{ NARC_phcgra_pmdp_236_m_lz_dat, NARC_phcgra_pmdp_236_m_lz_dat, },
	{ NARC_phcgra_pmdp_237_m_lz_dat, NARC_phcgra_pmdp_237_m_lz_dat, },
	{ NARC_phcgra_pmdp_238_m_lz_dat, NARC_phcgra_pmdp_238_m_lz_dat, },
	{ NARC_phcgra_pmdp_239_m_lz_dat, NARC_phcgra_pmdp_239_m_lz_dat, },
	{ NARC_phcgra_pmdp_240_m_lz_dat, NARC_phcgra_pmdp_240_m_lz_dat, },
	{ NARC_phcgra_pmdp_241_m_lz_dat, NARC_phcgra_pmdp_241_m_lz_dat, },
	{ NARC_phcgra_pmdp_242_m_lz_dat, NARC_phcgra_pmdp_242_m_lz_dat, },
	{ NARC_phcgra_pmdp_243_m_lz_dat, NARC_phcgra_pmdp_243_m_lz_dat, },
	{ NARC_phcgra_pmdp_244_m_lz_dat, NARC_phcgra_pmdp_244_m_lz_dat, },
	{ NARC_phcgra_pmdp_245_m_lz_dat, NARC_phcgra_pmdp_245_m_lz_dat, },
	{ NARC_phcgra_pmdp_246_m_lz_dat, NARC_phcgra_pmdp_246_m_lz_dat, },
	{ NARC_phcgra_pmdp_247_m_lz_dat, NARC_phcgra_pmdp_247_m_lz_dat, },
	{ NARC_phcgra_pmdp_248_m_lz_dat, NARC_phcgra_pmdp_248_m_lz_dat, },
	{ NARC_phcgra_pmdp_249_m_lz_dat, NARC_phcgra_pmdp_249_m_lz_dat, },
	{ NARC_phcgra_pmdp_250_m_lz_dat, NARC_phcgra_pmdp_250_m_lz_dat, },
	{ NARC_phcgra_pmdp_251_m_lz_dat, NARC_phcgra_pmdp_251_m_lz_dat, },
	{ NARC_phcgra_pmdp_252_m_lz_dat, NARC_phcgra_pmdp_252_m_lz_dat, },
	{ NARC_phcgra_pmdp_253_m_lz_dat, NARC_phcgra_pmdp_253_m_lz_dat, },
	{ NARC_phcgra_pmdp_254_m_lz_dat, NARC_phcgra_pmdp_254_m_lz_dat, },
	{ NARC_phcgra_pmdp_255_m_lz_dat, NARC_phcgra_pmdp_255_f_lz_dat, },
	{ NARC_phcgra_pmdp_256_m_lz_dat, NARC_phcgra_pmdp_256_f_lz_dat, },
	{ NARC_phcgra_pmdp_257_m_lz_dat, NARC_phcgra_pmdp_257_f_lz_dat, },
	{ NARC_phcgra_pmdp_258_m_lz_dat, NARC_phcgra_pmdp_258_m_lz_dat, },
	{ NARC_phcgra_pmdp_259_m_lz_dat, NARC_phcgra_pmdp_259_m_lz_dat, },
	{ NARC_phcgra_pmdp_260_m_lz_dat, NARC_phcgra_pmdp_260_m_lz_dat, },
	{ NARC_phcgra_pmdp_261_m_lz_dat, NARC_phcgra_pmdp_261_m_lz_dat, },
	{ NARC_phcgra_pmdp_262_m_lz_dat, NARC_phcgra_pmdp_262_m_lz_dat, },
	{ NARC_phcgra_pmdp_263_m_lz_dat, NARC_phcgra_pmdp_263_m_lz_dat, },
	{ NARC_phcgra_pmdp_264_m_lz_dat, NARC_phcgra_pmdp_264_m_lz_dat, },
	{ NARC_phcgra_pmdp_265_m_lz_dat, NARC_phcgra_pmdp_265_m_lz_dat, },
	{ NARC_phcgra_pmdp_266_m_lz_dat, NARC_phcgra_pmdp_266_m_lz_dat, },
	{ NARC_phcgra_pmdp_267_m_lz_dat, NARC_phcgra_pmdp_267_f_lz_dat, },
	{ NARC_phcgra_pmdp_268_m_lz_dat, NARC_phcgra_pmdp_268_m_lz_dat, },
	{ NARC_phcgra_pmdp_269_m_lz_dat, NARC_phcgra_pmdp_269_f_lz_dat, },
	{ NARC_phcgra_pmdp_270_m_lz_dat, NARC_phcgra_pmdp_270_m_lz_dat, },
	{ NARC_phcgra_pmdp_271_m_lz_dat, NARC_phcgra_pmdp_271_m_lz_dat, },
	{ NARC_phcgra_pmdp_272_m_lz_dat, NARC_phcgra_pmdp_272_f_lz_dat, },
	{ NARC_phcgra_pmdp_273_m_lz_dat, NARC_phcgra_pmdp_273_m_lz_dat, },
	{ NARC_phcgra_pmdp_274_m_lz_dat, NARC_phcgra_pmdp_274_f_lz_dat, },
	{ NARC_phcgra_pmdp_275_m_lz_dat, NARC_phcgra_pmdp_275_f_lz_dat, },
	{ NARC_phcgra_pmdp_276_m_lz_dat, NARC_phcgra_pmdp_276_m_lz_dat, },
	{ NARC_phcgra_pmdp_277_m_lz_dat, NARC_phcgra_pmdp_277_m_lz_dat, },
	{ NARC_phcgra_pmdp_278_m_lz_dat, NARC_phcgra_pmdp_278_m_lz_dat, },
	{ NARC_phcgra_pmdp_279_m_lz_dat, NARC_phcgra_pmdp_279_m_lz_dat, },
	{ NARC_phcgra_pmdp_280_m_lz_dat, NARC_phcgra_pmdp_280_m_lz_dat, },
	{ NARC_phcgra_pmdp_281_m_lz_dat, NARC_phcgra_pmdp_281_m_lz_dat, },
	{ NARC_phcgra_pmdp_282_m_lz_dat, NARC_phcgra_pmdp_282_m_lz_dat, },
	{ NARC_phcgra_pmdp_283_m_lz_dat, NARC_phcgra_pmdp_283_m_lz_dat, },
	{ NARC_phcgra_pmdp_284_m_lz_dat, NARC_phcgra_pmdp_284_m_lz_dat, },
	{ NARC_phcgra_pmdp_285_m_lz_dat, NARC_phcgra_pmdp_285_m_lz_dat, },
	{ NARC_phcgra_pmdp_286_m_lz_dat, NARC_phcgra_pmdp_286_m_lz_dat, },
	{ NARC_phcgra_pmdp_287_m_lz_dat, NARC_phcgra_pmdp_287_m_lz_dat, },
	{ NARC_phcgra_pmdp_288_m_lz_dat, NARC_phcgra_pmdp_288_m_lz_dat, },
	{ NARC_phcgra_pmdp_289_m_lz_dat, NARC_phcgra_pmdp_289_m_lz_dat, },
	{ NARC_phcgra_pmdp_290_m_lz_dat, NARC_phcgra_pmdp_290_m_lz_dat, },
	{ NARC_phcgra_pmdp_291_m_lz_dat, NARC_phcgra_pmdp_291_m_lz_dat, },
	{ NARC_phcgra_pmdp_292_m_lz_dat, NARC_phcgra_pmdp_292_m_lz_dat, },
	{ NARC_phcgra_pmdp_293_m_lz_dat, NARC_phcgra_pmdp_293_m_lz_dat, },
	{ NARC_phcgra_pmdp_294_m_lz_dat, NARC_phcgra_pmdp_294_m_lz_dat, },
	{ NARC_phcgra_pmdp_295_m_lz_dat, NARC_phcgra_pmdp_295_m_lz_dat, },
	{ NARC_phcgra_pmdp_296_m_lz_dat, NARC_phcgra_pmdp_296_m_lz_dat, },
	{ NARC_phcgra_pmdp_297_m_lz_dat, NARC_phcgra_pmdp_297_m_lz_dat, },
	{ NARC_phcgra_pmdp_298_m_lz_dat, NARC_phcgra_pmdp_298_m_lz_dat, },
	{ NARC_phcgra_pmdp_299_m_lz_dat, NARC_phcgra_pmdp_299_m_lz_dat, },
	{ NARC_phcgra_pmdp_300_m_lz_dat, NARC_phcgra_pmdp_300_m_lz_dat, },
	{ NARC_phcgra_pmdp_301_m_lz_dat, NARC_phcgra_pmdp_301_m_lz_dat, },
	{ NARC_phcgra_pmdp_302_m_lz_dat, NARC_phcgra_pmdp_302_m_lz_dat, },
	{ NARC_phcgra_pmdp_303_m_lz_dat, NARC_phcgra_pmdp_303_m_lz_dat, },
	{ NARC_phcgra_pmdp_304_m_lz_dat, NARC_phcgra_pmdp_304_m_lz_dat, },
	{ NARC_phcgra_pmdp_305_m_lz_dat, NARC_phcgra_pmdp_305_m_lz_dat, },
	{ NARC_phcgra_pmdp_306_m_lz_dat, NARC_phcgra_pmdp_306_m_lz_dat, },
	{ NARC_phcgra_pmdp_307_m_lz_dat, NARC_phcgra_pmdp_307_f_lz_dat, },
	{ NARC_phcgra_pmdp_308_m_lz_dat, NARC_phcgra_pmdp_308_f_lz_dat, },
	{ NARC_phcgra_pmdp_309_m_lz_dat, NARC_phcgra_pmdp_309_m_lz_dat, },
	{ NARC_phcgra_pmdp_310_m_lz_dat, NARC_phcgra_pmdp_310_m_lz_dat, },
	{ NARC_phcgra_pmdp_311_m_lz_dat, NARC_phcgra_pmdp_311_m_lz_dat, },
	{ NARC_phcgra_pmdp_312_m_lz_dat, NARC_phcgra_pmdp_312_m_lz_dat, },
	{ NARC_phcgra_pmdp_313_m_lz_dat, NARC_phcgra_pmdp_313_m_lz_dat, },
	{ NARC_phcgra_pmdp_314_m_lz_dat, NARC_phcgra_pmdp_314_m_lz_dat, },
	{ NARC_phcgra_pmdp_315_m_lz_dat, NARC_phcgra_pmdp_315_f_lz_dat, },
	{ NARC_phcgra_pmdp_316_m_lz_dat, NARC_phcgra_pmdp_316_f_lz_dat, },
	{ NARC_phcgra_pmdp_317_m_lz_dat, NARC_phcgra_pmdp_317_f_lz_dat, },
	{ NARC_phcgra_pmdp_318_m_lz_dat, NARC_phcgra_pmdp_318_m_lz_dat, },
	{ NARC_phcgra_pmdp_319_m_lz_dat, NARC_phcgra_pmdp_319_m_lz_dat, },
	{ NARC_phcgra_pmdp_320_m_lz_dat, NARC_phcgra_pmdp_320_m_lz_dat, },
	{ NARC_phcgra_pmdp_321_m_lz_dat, NARC_phcgra_pmdp_321_m_lz_dat, },
	{ NARC_phcgra_pmdp_322_m_lz_dat, NARC_phcgra_pmdp_322_f_lz_dat, },
	{ NARC_phcgra_pmdp_323_m_lz_dat, NARC_phcgra_pmdp_323_f_lz_dat, },
	{ NARC_phcgra_pmdp_324_m_lz_dat, NARC_phcgra_pmdp_324_m_lz_dat, },
	{ NARC_phcgra_pmdp_325_m_lz_dat, NARC_phcgra_pmdp_325_m_lz_dat, },
	{ NARC_phcgra_pmdp_326_m_lz_dat, NARC_phcgra_pmdp_326_m_lz_dat, },
	{ NARC_phcgra_pmdp_327_m_lz_dat, NARC_phcgra_pmdp_327_m_lz_dat, },
	{ NARC_phcgra_pmdp_328_m_lz_dat, NARC_phcgra_pmdp_328_m_lz_dat, },
	{ NARC_phcgra_pmdp_329_m_lz_dat, NARC_phcgra_pmdp_329_m_lz_dat, },
	{ NARC_phcgra_pmdp_330_m_lz_dat, NARC_phcgra_pmdp_330_m_lz_dat, },
	{ NARC_phcgra_pmdp_331_m_lz_dat, NARC_phcgra_pmdp_331_m_lz_dat, },
	{ NARC_phcgra_pmdp_332_m_lz_dat, NARC_phcgra_pmdp_332_f_lz_dat, },
	{ NARC_phcgra_pmdp_333_m_lz_dat, NARC_phcgra_pmdp_333_m_lz_dat, },
	{ NARC_phcgra_pmdp_334_m_lz_dat, NARC_phcgra_pmdp_334_m_lz_dat, },
	{ NARC_phcgra_pmdp_335_m_lz_dat, NARC_phcgra_pmdp_335_m_lz_dat, },
	{ NARC_phcgra_pmdp_336_m_lz_dat, NARC_phcgra_pmdp_336_m_lz_dat, },
	{ NARC_phcgra_pmdp_337_m_lz_dat, NARC_phcgra_pmdp_337_m_lz_dat, },
	{ NARC_phcgra_pmdp_338_m_lz_dat, NARC_phcgra_pmdp_338_m_lz_dat, },
	{ NARC_phcgra_pmdp_339_m_lz_dat, NARC_phcgra_pmdp_339_m_lz_dat, },
	{ NARC_phcgra_pmdp_340_m_lz_dat, NARC_phcgra_pmdp_340_m_lz_dat, },
	{ NARC_phcgra_pmdp_341_m_lz_dat, NARC_phcgra_pmdp_341_m_lz_dat, },
	{ NARC_phcgra_pmdp_342_m_lz_dat, NARC_phcgra_pmdp_342_m_lz_dat, },
	{ NARC_phcgra_pmdp_343_m_lz_dat, NARC_phcgra_pmdp_343_m_lz_dat, },
	{ NARC_phcgra_pmdp_344_m_lz_dat, NARC_phcgra_pmdp_344_m_lz_dat, },
	{ NARC_phcgra_pmdp_345_m_lz_dat, NARC_phcgra_pmdp_345_m_lz_dat, },
	{ NARC_phcgra_pmdp_346_m_lz_dat, NARC_phcgra_pmdp_346_m_lz_dat, },
	{ NARC_phcgra_pmdp_347_m_lz_dat, NARC_phcgra_pmdp_347_m_lz_dat, },
	{ NARC_phcgra_pmdp_348_m_lz_dat, NARC_phcgra_pmdp_348_m_lz_dat, },
	{ NARC_phcgra_pmdp_349_m_lz_dat, NARC_phcgra_pmdp_349_m_lz_dat, },
	{ NARC_phcgra_pmdp_350_m_lz_dat, NARC_phcgra_pmdp_350_f_lz_dat, },
	{ NARC_phcgra_pmdp_351_m_lz_dat, NARC_phcgra_pmdp_351_m_lz_dat, },
	{ NARC_phcgra_pmdp_352_m_lz_dat, NARC_phcgra_pmdp_352_m_lz_dat, },
	{ NARC_phcgra_pmdp_353_m_lz_dat, NARC_phcgra_pmdp_353_m_lz_dat, },
	{ NARC_phcgra_pmdp_354_m_lz_dat, NARC_phcgra_pmdp_354_m_lz_dat, },
	{ NARC_phcgra_pmdp_355_m_lz_dat, NARC_phcgra_pmdp_355_m_lz_dat, },
	{ NARC_phcgra_pmdp_356_m_lz_dat, NARC_phcgra_pmdp_356_m_lz_dat, },
	{ NARC_phcgra_pmdp_357_m_lz_dat, NARC_phcgra_pmdp_357_m_lz_dat, },
	{ NARC_phcgra_pmdp_358_m_lz_dat, NARC_phcgra_pmdp_358_m_lz_dat, },
	{ NARC_phcgra_pmdp_359_m_lz_dat, NARC_phcgra_pmdp_359_m_lz_dat, },
	{ NARC_phcgra_pmdp_360_m_lz_dat, NARC_phcgra_pmdp_360_m_lz_dat, },
	{ NARC_phcgra_pmdp_361_m_lz_dat, NARC_phcgra_pmdp_361_m_lz_dat, },
	{ NARC_phcgra_pmdp_362_m_lz_dat, NARC_phcgra_pmdp_362_m_lz_dat, },
	{ NARC_phcgra_pmdp_363_m_lz_dat, NARC_phcgra_pmdp_363_m_lz_dat, },
	{ NARC_phcgra_pmdp_364_m_lz_dat, NARC_phcgra_pmdp_364_m_lz_dat, },
	{ NARC_phcgra_pmdp_365_m_lz_dat, NARC_phcgra_pmdp_365_m_lz_dat, },
	{ NARC_phcgra_pmdp_366_m_lz_dat, NARC_phcgra_pmdp_366_m_lz_dat, },
	{ NARC_phcgra_pmdp_367_m_lz_dat, NARC_phcgra_pmdp_367_m_lz_dat, },
	{ NARC_phcgra_pmdp_368_m_lz_dat, NARC_phcgra_pmdp_368_m_lz_dat, },
	{ NARC_phcgra_pmdp_369_m_lz_dat, NARC_phcgra_pmdp_369_f_lz_dat, },
	{ NARC_phcgra_pmdp_370_m_lz_dat, NARC_phcgra_pmdp_370_m_lz_dat, },
	{ NARC_phcgra_pmdp_371_m_lz_dat, NARC_phcgra_pmdp_371_m_lz_dat, },
	{ NARC_phcgra_pmdp_372_m_lz_dat, NARC_phcgra_pmdp_372_m_lz_dat, },
	{ NARC_phcgra_pmdp_373_m_lz_dat, NARC_phcgra_pmdp_373_m_lz_dat, },
	{ NARC_phcgra_pmdp_374_m_lz_dat, NARC_phcgra_pmdp_374_m_lz_dat, },
	{ NARC_phcgra_pmdp_375_m_lz_dat, NARC_phcgra_pmdp_375_m_lz_dat, },
	{ NARC_phcgra_pmdp_376_m_lz_dat, NARC_phcgra_pmdp_376_m_lz_dat, },
	{ NARC_phcgra_pmdp_377_m_lz_dat, NARC_phcgra_pmdp_377_m_lz_dat, },
	{ NARC_phcgra_pmdp_378_m_lz_dat, NARC_phcgra_pmdp_378_m_lz_dat, },
	{ NARC_phcgra_pmdp_379_m_lz_dat, NARC_phcgra_pmdp_379_m_lz_dat, },
	{ NARC_phcgra_pmdp_380_m_lz_dat, NARC_phcgra_pmdp_380_m_lz_dat, },
	{ NARC_phcgra_pmdp_381_m_lz_dat, NARC_phcgra_pmdp_381_m_lz_dat, },
	{ NARC_phcgra_pmdp_382_m_lz_dat, NARC_phcgra_pmdp_382_m_lz_dat, },
	{ NARC_phcgra_pmdp_383_m_lz_dat, NARC_phcgra_pmdp_383_m_lz_dat, },
	{ NARC_phcgra_pmdp_384_m_lz_dat, NARC_phcgra_pmdp_384_m_lz_dat, },
	{ NARC_phcgra_pmdp_385_m_lz_dat, NARC_phcgra_pmdp_385_m_lz_dat, },
	{ NARC_phcgra_pmdp_386_m_lz_dat, NARC_phcgra_pmdp_386_m_lz_dat, },
	{ NARC_phcgra_pmdp_432_m_lz_dat, NARC_phcgra_pmdp_432_m_lz_dat, },
	{ NARC_phcgra_pmdp_433_m_lz_dat, NARC_phcgra_pmdp_433_m_lz_dat, },
	{ NARC_phcgra_pmdp_434_m_lz_dat, NARC_phcgra_pmdp_434_m_lz_dat, },
	{ NARC_phcgra_pmdp_430_m_lz_dat, NARC_phcgra_pmdp_430_m_lz_dat, },
	{ NARC_phcgra_pmdp_435_m_lz_dat, NARC_phcgra_pmdp_435_m_lz_dat, },
	{ NARC_phcgra_pmdp_436_m_lz_dat, NARC_phcgra_pmdp_436_m_lz_dat, },
	{ NARC_phcgra_pmdp_431_m_lz_dat, NARC_phcgra_pmdp_431_m_lz_dat, },
	{ NARC_phcgra_pmdp_437_m_lz_dat, NARC_phcgra_pmdp_437_m_lz_dat, },
	{ NARC_phcgra_pmdp_438_m_lz_dat, NARC_phcgra_pmdp_438_m_lz_dat, },
	{ NARC_phcgra_pmdp_429_m_lz_dat, NARC_phcgra_pmdp_429_f_lz_dat, },
	{ NARC_phcgra_pmdp_448_m_lz_dat, NARC_phcgra_pmdp_448_f_lz_dat, },
	{ NARC_phcgra_pmdp_449_m_lz_dat, NARC_phcgra_pmdp_449_f_lz_dat, },
	{ NARC_phcgra_pmdp_461_m_lz_dat, NARC_phcgra_pmdp_461_f_lz_dat, },
	{ NARC_phcgra_pmdp_462_m_lz_dat, NARC_phcgra_pmdp_462_f_lz_dat, },
	{ NARC_phcgra_pmdp_480_m_lz_dat, NARC_phcgra_pmdp_480_f_lz_dat, },
	{ NARC_phcgra_pmdp_481_m_lz_dat, NARC_phcgra_pmdp_481_f_lz_dat, },
	{ NARC_phcgra_pmdp_472_m_lz_dat, NARC_phcgra_pmdp_472_f_lz_dat, },
	{ NARC_phcgra_pmdp_473_m_lz_dat, NARC_phcgra_pmdp_473_f_lz_dat, },
	{ NARC_phcgra_pmdp_474_m_lz_dat, NARC_phcgra_pmdp_474_f_lz_dat, },
	{ NARC_phcgra_pmdp_428_m_lz_dat, NARC_phcgra_pmdp_428_m_lz_dat, },
	{ NARC_phcgra_pmdp_421_m_lz_dat, NARC_phcgra_pmdp_421_f_lz_dat, },
	{ NARC_phcgra_pmdp_489_m_lz_dat, NARC_phcgra_pmdp_489_m_lz_dat, },
	{ NARC_phcgra_pmdp_490_m_lz_dat, NARC_phcgra_pmdp_490_m_lz_dat, },
	{ NARC_phcgra_pmdp_487_m_lz_dat, NARC_phcgra_pmdp_487_m_lz_dat, },
	{ NARC_phcgra_pmdp_488_m_lz_dat, NARC_phcgra_pmdp_488_m_lz_dat, },
	{ NARC_phcgra_pmdp_455_m_lz_dat, NARC_phcgra_pmdp_455_m_lz_dat, },
	{ NARC_phcgra_pmdp_457_m_lz_dat, NARC_phcgra_pmdp_457_m_lz_dat, },
	{ NARC_phcgra_pmdp_456_m_lz_dat, NARC_phcgra_pmdp_456_m_lz_dat, },
	{ NARC_phcgra_pmdp_470_m_lz_dat, NARC_phcgra_pmdp_470_f_lz_dat, },
	{ NARC_phcgra_pmdp_471_m_lz_dat, NARC_phcgra_pmdp_471_m_lz_dat, },
	{ NARC_phcgra_pmdp_477_m_lz_dat, NARC_phcgra_pmdp_477_f_lz_dat, },
	{ NARC_phcgra_pmdp_418_m_lz_dat, NARC_phcgra_pmdp_418_f_lz_dat, },
	{ NARC_phcgra_pmdp_440_m_lz_dat, NARC_phcgra_pmdp_440_f_lz_dat, },
	{ NARC_phcgra_pmdp_482_m_lz_dat, NARC_phcgra_pmdp_482_m_lz_dat, },
	{ NARC_phcgra_pmdp_483_m_lz_dat, NARC_phcgra_pmdp_483_m_lz_dat, },
	{ NARC_phcgra_pmdp_458_m_lz_dat, NARC_phcgra_pmdp_458_m_lz_dat, },
	{ NARC_phcgra_pmdp_459_m_lz_dat, NARC_phcgra_pmdp_459_m_lz_dat, },
	{ NARC_phcgra_pmdp_496_m_lz_dat, NARC_phcgra_pmdp_496_f_lz_dat, },
	{ NARC_phcgra_pmdp_450_m_lz_dat, NARC_phcgra_pmdp_450_m_lz_dat, },
	{ NARC_phcgra_pmdp_451_m_lz_dat, NARC_phcgra_pmdp_451_m_lz_dat, },
	{ NARC_phcgra_pmdp_420_m_lz_dat, NARC_phcgra_pmdp_420_m_lz_dat, },
	{ NARC_phcgra_pmdp_454_m_lz_dat, NARC_phcgra_pmdp_454_m_lz_dat, },
	{ NARC_phcgra_pmdp_500_m_lz_dat, NARC_phcgra_pmdp_500_m_lz_dat, },
	{ NARC_phcgra_pmdp_494_m_lz_dat, NARC_phcgra_pmdp_494_m_lz_dat, },
	{ NARC_phcgra_pmdp_426_m_lz_dat, NARC_phcgra_pmdp_426_m_lz_dat, },
	{ NARC_phcgra_pmdp_463_m_lz_dat, NARC_phcgra_pmdp_463_m_lz_dat, },
	{ NARC_phcgra_pmdp_445_m_lz_dat, NARC_phcgra_pmdp_445_m_lz_dat, },
	{ NARC_phcgra_pmdp_468_m_lz_dat, NARC_phcgra_pmdp_468_m_lz_dat, },
	{ NARC_phcgra_pmdp_469_m_lz_dat, NARC_phcgra_pmdp_469_m_lz_dat, },
	{ NARC_phcgra_pmdp_478_m_lz_dat, NARC_phcgra_pmdp_478_m_lz_dat, },
	{ NARC_phcgra_pmdp_479_m_lz_dat, NARC_phcgra_pmdp_479_m_lz_dat, },
	{ NARC_phcgra_pmdp_413_m_lz_dat, NARC_phcgra_pmdp_413_m_lz_dat, },
	{ NARC_phcgra_pmdp_414_m_lz_dat, NARC_phcgra_pmdp_414_m_lz_dat, },
	{ NARC_phcgra_pmdp_444_m_lz_dat, NARC_phcgra_pmdp_444_m_lz_dat, },
	{ NARC_phcgra_pmdp_419_m_lz_dat, NARC_phcgra_pmdp_419_m_lz_dat, },
	{ NARC_phcgra_pmdp_460_m_lz_dat, NARC_phcgra_pmdp_460_m_lz_dat, },
	{ NARC_phcgra_pmdp_491_m_lz_dat, NARC_phcgra_pmdp_491_f_lz_dat, },
	{ NARC_phcgra_pmdp_492_m_lz_dat, NARC_phcgra_pmdp_492_f_lz_dat, },
	{ NARC_phcgra_pmdp_493_m_lz_dat, NARC_phcgra_pmdp_493_f_lz_dat, },
	{ NARC_phcgra_pmdp_412_m_lz_dat, NARC_phcgra_pmdp_412_m_lz_dat, },
	{ NARC_phcgra_pmdp_439_m_lz_dat, NARC_phcgra_pmdp_439_m_lz_dat, },
	{ NARC_phcgra_pmdp_416_m_lz_dat, NARC_phcgra_pmdp_416_m_lz_dat, },
	{ NARC_phcgra_pmdp_464_m_lz_dat, NARC_phcgra_pmdp_464_f_lz_dat, },
	{ NARC_phcgra_pmdp_465_m_lz_dat, NARC_phcgra_pmdp_465_f_lz_dat, },
	{ NARC_phcgra_pmdp_485_m_lz_dat, NARC_phcgra_pmdp_485_m_lz_dat, },
	{ NARC_phcgra_pmdp_486_m_lz_dat, NARC_phcgra_pmdp_486_m_lz_dat, },
	{ NARC_phcgra_pmdp_452_m_lz_dat, NARC_phcgra_pmdp_452_f_lz_dat, },
	{ NARC_phcgra_pmdp_453_m_lz_dat, NARC_phcgra_pmdp_453_f_lz_dat, },
	{ NARC_phcgra_pmdp_484_m_lz_dat, NARC_phcgra_pmdp_484_m_lz_dat, },
	{ NARC_phcgra_pmdp_466_m_lz_dat, NARC_phcgra_pmdp_466_f_lz_dat, },
	{ NARC_phcgra_pmdp_467_m_lz_dat, NARC_phcgra_pmdp_467_f_lz_dat, },
	{ NARC_phcgra_pmdp_417_m_lz_dat, NARC_phcgra_pmdp_417_m_lz_dat, },
	{ NARC_phcgra_pmdp_475_m_lz_dat, NARC_phcgra_pmdp_475_f_lz_dat, },
	{ NARC_phcgra_pmdp_476_m_lz_dat, NARC_phcgra_pmdp_476_f_lz_dat, },
	{ NARC_phcgra_pmdp_415_m_lz_dat, NARC_phcgra_pmdp_415_f_lz_dat, },
	{ NARC_phcgra_pmdp_443_m_lz_dat, NARC_phcgra_pmdp_443_m_lz_dat, },
	{ NARC_phcgra_pmdp_501_m_lz_dat, NARC_phcgra_pmdp_501_m_lz_dat, },
	{ NARC_phcgra_pmdp_446_m_lz_dat, NARC_phcgra_pmdp_446_f_lz_dat, },
	{ NARC_phcgra_pmdp_422_m_lz_dat, NARC_phcgra_pmdp_422_f_lz_dat, },
	{ NARC_phcgra_pmdp_427_m_lz_dat, NARC_phcgra_pmdp_427_m_lz_dat, },
	{ NARC_phcgra_pmdp_502_m_lz_dat, NARC_phcgra_pmdp_502_m_lz_dat, },
	{ NARC_phcgra_pmdp_495_m_lz_dat, NARC_phcgra_pmdp_495_m_lz_dat, },
	{ NARC_phcgra_pmdp_499_m_lz_dat, NARC_phcgra_pmdp_499_m_lz_dat, },
	{ NARC_phcgra_pmdp_505_m_lz_dat, NARC_phcgra_pmdp_505_m_lz_dat, },
	{ NARC_phcgra_pmdp_506_m_lz_dat, NARC_phcgra_pmdp_506_m_lz_dat, },
	{ NARC_phcgra_pmdp_447_m_lz_dat, NARC_phcgra_pmdp_447_m_lz_dat, },
	{ NARC_phcgra_pmdp_424_m_lz_dat, NARC_phcgra_pmdp_424_f_lz_dat, },
	{ NARC_phcgra_pmdp_504_m_lz_dat, NARC_phcgra_pmdp_504_m_lz_dat, },
	{ NARC_phcgra_pmdp_498_m_lz_dat, NARC_phcgra_pmdp_498_m_lz_dat, },
	{ NARC_phcgra_pmdp_497_m_lz_dat, NARC_phcgra_pmdp_497_m_lz_dat, },
	{ NARC_phcgra_pmdp_423_m_lz_dat, NARC_phcgra_pmdp_423_m_lz_dat, },
	{ NARC_phcgra_pmdp_425_m_lz_dat, NARC_phcgra_pmdp_425_m_lz_dat, },
	{ NARC_phcgra_pmdp_519_m_lz_dat, NARC_phcgra_pmdp_519_m_lz_dat, },
	{ NARC_phcgra_pmdp_511_m_lz_dat, NARC_phcgra_pmdp_511_m_lz_dat, },
	{ NARC_phcgra_pmdp_512_m_lz_dat, NARC_phcgra_pmdp_512_m_lz_dat, },
	{ NARC_phcgra_pmdp_513_m_lz_dat, NARC_phcgra_pmdp_513_m_lz_dat, },
	{ NARC_phcgra_pmdp_514_m_lz_dat, NARC_phcgra_pmdp_514_m_lz_dat, },
	{ NARC_phcgra_pmdp_515_m_lz_dat, NARC_phcgra_pmdp_515_m_lz_dat, },
	{ NARC_phcgra_pmdp_508_m_lz_dat, NARC_phcgra_pmdp_508_m_lz_dat, },
	{ NARC_phcgra_pmdp_510_m_lz_dat, NARC_phcgra_pmdp_510_m_lz_dat, },
	{ NARC_phcgra_pmdp_509_m_lz_dat, NARC_phcgra_pmdp_509_m_lz_dat, },
	{ NARC_phcgra_pmdp_507_m_lz_dat, NARC_phcgra_pmdp_507_m_lz_dat, },
	{ NARC_phcgra_pmdp_441_m_lz_dat, NARC_phcgra_pmdp_441_m_lz_dat, },
	{ NARC_phcgra_pmdp_442_m_lz_dat, NARC_phcgra_pmdp_442_m_lz_dat, },
	{ NARC_phcgra_pmdp_517_m_lz_dat, NARC_phcgra_pmdp_517_m_lz_dat, },
	{ NARC_phcgra_pmdp_516_m_lz_dat, NARC_phcgra_pmdp_516_m_lz_dat, },
	{ NARC_phcgra_pmdp_518_m_lz_dat, NARC_phcgra_pmdp_518_m_lz_dat, },

};

//============================================================================================
/**
 * @brief		アーカイバファイル取り出し用ヘッダデータ生成ルーチン（ポケモングラフィック）
 *
 * @param	[in]mons_no	生成するポケモンナンバー
 * @param	[in]sex		生成するポケモンの雌雄（PARA_MALE:♂　PARA_FEMALE:♀　PARA_UNK:Unknown）
 * @param	[in]form_no	生成するためのフォルムナンバー（ミノムッチ、ミノメスなど）
 *
 * @retval	int			アーカイブインデックスNO
 */
//============================================================================================
int	PhcLink_GraArcDataGet( const int mons_no, int sex, int  form_no )
{
	//フォルムナンバーが不正かどうかチェック
	form_no = PokeFuseiFormNoCheck(mons_no,form_no);

	switch(mons_no){
	//ミノムッチ
	case MONSNO_MINOMUTTI:
		return NARC_phcgra_pmdp_455_kusa_lz_dat+form_no;
		break;
	//ミノメス
	case MONSNO_MINOMESU:
		return NARC_phcgra_pmdp_457_kusa_lz_dat+form_no;
		break;
	//シーウシ
	case MONSNO_SIIUSI:
		return NARC_phcgra_pmdp_458_west_lz_dat+form_no;
		break;
	//シードルゴ
	case MONSNO_SIIDORUGO:
		return NARC_phcgra_pmdp_459_west_lz_dat+form_no;
		break;
	//チェリシュ
	case MONSNO_THERISYU:
		return NARC_phcgra_pmdp_483_normal_lz_dat+form_no;
		break;
	//アウス
	case MONSNO_AUSU:
		return NARC_phcgra_pmdp_518_normal_lz_dat+form_no;
		break;
	//ポワルン
	case MONSNO_POWARUN:
		return NARC_phcgra_pmdp_351_normal_lz_dat+form_no;
		break;
	//デオキシス
	case MONSNO_DEOKISISU:
		return NARC_phcgra_pmdp_386_n_lz_dat+form_no;
		break;
	//アンノーン
	case MONSNO_ANNOON:
		return NARC_phcgra_pmdp_una_o_lz_dat+form_no;
		break;
	//ダメタマゴ
//	case MONSNO_DAMETAMAGO:
//		return NARC_phcgra_pmdp_egg_normal_lz_dat;
//		break;
	//シェイミ
	case MONSNO_EURISU:		//プラチナで追加
		return NARC_phcgra_pmpl_516_normal_lz_dat+form_no;
		break;
	//ロトム
	case MONSNO_PURAZUMA:
		return NARC_phcgra_pmgs_519_normal_lz_dat+form_no;
		break;
	//ギラティナ
	case MONSNO_KIMAIRAN:
		return NARC_phcgra_pmgs_509_normal_lz_dat+form_no;
		break;
	// ピチュー			// 金銀で追加
	case MONSNO_PITYUU:
		return NARC_phcgra_pmgs_172_normal_lz_dat+form_no;
		break;
	default:
		if(sex!=PARA_FEMALE){
			sex=PARA_MALE;
		}
		return pokegra_sex_table[mons_no][sex];

		//パッチールの時は、ぶちデータを格納
//		if(mons_no==MONSNO_PATTIIRU){
//			ssa->strike_mons=MONSNO_PATTIIRU;
//		}
		break;
	}
}




#define NORMAL_COURSE_MAX		( 20 )		///< ワットでオープンする通常コースの最大数
#define JOHTO_COURSE_NUM		(  8 )		///< ワットでオープンするジョウトコースの最大数

//==============================================================================
/**
 * @brief   獲得ワット数でコースを増やす処理
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  none
 */
//==============================================================================
void PhcLink_OpenCourseCheck( PHCLINK_WORK *wk )
{
	u32 totalStep,totalWat,i,course_num;
	PhcSvData_GetTotalStepWat( wk->phc_svdata, &totalStep, &totalWat );

	// 全国図鑑フラグを取得しているなら
	if(ZukanWork_GetZenkokuZukanFlag(SaveData_GetZukanWork(wk->savedata))){
		course_num = NORMAL_COURSE_MAX;		// 全20コース
	}else{
		course_num = JOHTO_COURSE_NUM;		// 8コース
	}

	for(i=0;i<course_num;i++){
		// 必要ワットを持っていて
		if(PhcCourseData[i].need_wat<=totalWat){

			// まだコースフラグがオープンしていなかったら
			if(PhcSvData_GetCourseOpenFlag(wk->phc_svdata, i)==0){

				// コースフラグオープン
				PhcSvData_SetCourseOpenFlag(wk->phc_svdata, i);

				// オープン告知用ワークに保存
				wk->open_course_id = i;

				// オープンは引き取り時に一つしかオープンしない（複数条件越していても無視）
				break;
			}
		}
	}
}


//=============================================================================================
/**
 * @brief	 現在のワットは新しいコースを開くのにあとどれだけ必要か
 *
 * @param   wk		PHC画面ワーク
 * @param   wat		ワット
 *
 * @retval  int		-1:もうオープンするコースはない 0:今でも足りてる 0以上:必要なワット
 */
//=============================================================================================
int PhcLink_SearchOpenCourse( PHCLINK_WORK *wk, int wat )
{
	int i,course_num;

	// 全国図鑑フラグを取得しているなら
	if(ZukanWork_GetZenkokuZukanFlag(SaveData_GetZukanWork(wk->savedata))){
		course_num = NORMAL_COURSE_MAX;		// 全20コース
	}else{
		course_num = JOHTO_COURSE_NUM;		// 8コース
	}



	for(i=0;i<course_num;i++){
		// まだオープンしてないコースの
		if(PhcSvData_GetCourseOpenFlag(wk->phc_svdata, i)==0){

			// 条件のワットに足りているか
			if(PhcCourseData[i].need_wat > wat ){
				return PhcCourseData[i].need_wat - wat;
			}

			// 今のワットで条件は超えている
			return 0;
		}
	}

	// もう全部コースはオープンしている
	return -1;
}


//=============================================================================================
/**
 * @brief	 はい・いいえ処理画面初期化
 *
 * @param   wk		PHC画面ワーク
 * @param   first	カーソルの初期位置（0:はい 1:いいえ)
 */
//=============================================================================================
void PhcLinkBmp_YesnoInit( PHCLINK_WORK *wk, int first )
{

	PhcLink_BgGraphicSet( wk, GF_BGL_FRAME2_M, NARC_phc_ds_phcds_yn_d_lz_nscr );
	PhcLinkObj_CursorPosAppearSet( wk, 0 );
	PhcLinkBmp_StrPrintColor_M( wk, PL_BMP_B_SEL_2_0, wk->YesNoStr[0], FONT_TOUCH, PHCCOL_B_BLACK );
	PhcLinkBmp_StrPrintColor_M( wk, PL_BMP_B_SEL_2_1, wk->YesNoStr[1], FONT_TOUCH, PHCCOL_B_BLACK );

	// カーソルの初期位置は「いいえ」
	PhcLinkObj_CursorPosAppearSet( wk, first);
	wk->cursor_pos = first;
	wk->yesno_seq  = 0;
}

//=============================================================================================
/**
 * @brief	 はい・いいえ処理画面初期化
 *
 * @param   wk		PHC画面ワーク
 * @param   first	カーソルの初期位置（0:はい 1:いいえ)
 */
//=============================================================================================
void PhcLinkBmp_StepClearYesnoInit( PHCLINK_WORK *wk, int first )
{
	STRBUF *yesstr = MSGMAN_AllocString( wk->msg_man, phc_msg_hosuu_yes );
	STRBUF *nostr  = MSGMAN_AllocString( wk->msg_man, phc_msg_hosuu_no );

	PhcLink_BgGraphicSet( wk, GF_BGL_FRAME2_M, NARC_phc_ds_phcds_yn_d_lz_nscr );
	PhcLinkObj_CursorPosAppearSet( wk, 0 );
	PhcLinkBmp_StrPrintColor_M( wk, PL_BMP_B_SEL_2_0, yesstr, FONT_TOUCH, PHCCOL_B_BLACK );
	PhcLinkBmp_StrPrintColor_M( wk, PL_BMP_B_SEL_2_1, nostr,  FONT_TOUCH, PHCCOL_B_BLACK );

	// カーソルの初期位置は「いいえ」
	PhcLinkObj_CursorPosAppearSet( wk, first);
	wk->cursor_pos = first;
	wk->yesno_seq  = 0;

	STRBUF_Delete(nostr);
	STRBUF_Delete(yesstr);
}


//=============================================================================================
/**
 * @brief	 はい・いいえ決定待ち処理
 *
 * @param   wk		PHC画面ワーク
 *
 * @retval  int		PHC_YESNO_YES,PHC_YESNO_NO,PHC_YESNO_NONE
 */
//=============================================================================================
int PhcLinkBmp_YesnoWait( PHCLINK_WORK *wk )
{
	// 選択シーケンス
	if(wk->yesno_seq==0){
		switch(PhcLink_GetTouchTrg( PHC_TOUCH_YESNO_MODE )){
		case 0:
			wk->cursor_pos = 0;
			PhcLinkObj_CursorPosAppearSet( wk, 0);
			PhcLinkObj_CursorBlink( wk );
			Snd_SePlay(SEQ_SE_DP_DECIDE);
			wk->yesno_seq = 1;
			break;
		case 1:
			wk->cursor_pos = 2;
			PhcLinkObj_CursorPosAppearSet( wk, 1);
			PhcLinkObj_CursorBlink( wk );
			Snd_SePlay(SEQ_SE_DP_DECIDE);
			wk->yesno_seq = 1;
			break;
		case RECT_HIT_NONE:
			if(sys.trg&PAD_KEY_UP){
				if(wk->cursor_pos!=0){
					Snd_SePlay(SEQ_SE_DP_SELECT);
				}
				PhcLinkObj_CursorPosAppearSet( wk, 0);
				wk->cursor_pos = 0;
			}else if(sys.trg&PAD_KEY_DOWN){
				if(wk->cursor_pos!=1){
					Snd_SePlay(SEQ_SE_DP_SELECT);
				}
				PhcLinkObj_CursorPosAppearSet( wk, 1);
				wk->cursor_pos = 1;
			}else if(sys.trg&PAD_BUTTON_DECIDE){
				wk->yesno_seq = 1;
				PhcLinkObj_CursorBlink( wk );
				Snd_SePlay(SEQ_SE_DP_DECIDE);
			}else if(sys.trg&PAD_BUTTON_CANCEL){
				PhcLinkObj_CursorPosAppearSet( wk, 1);
				PhcLinkObj_CursorBlink( wk );
				wk->cursor_pos = 1;
				wk->yesno_seq  = 1;
				Snd_SePlay(SEQ_SE_DP_SELECT);
			}
			break;
		}
	}else if(wk->yesno_seq==1){
		if(CATS_ObjectAnimeActiveCheckCap(wk->cap[PLOBJ_ID_CURSOR])==FALSE){
			wk->yesno_seq = 2;
		}
	}else if(wk->yesno_seq==2){
		// 決定通知シーケンス
		if(wk->cursor_pos==0){
			return PHC_YESNO_YES;
		}else{
			return PHC_YESNO_NO;
		}

	}
	return PHC_YESNO_NONE;
}


//=============================================================================================
// タッチ範囲定義
//=============================================================================================
static const  RECT_HIT_TBL yesno_rect_data[] ={
	{  37,  76,  13, 239, },	// はい
	{  77, 115,  13, 239, },	// いいえ
 	{TP_HIT_END,0,0,0},
};

static const  RECT_HIT_TBL select_1_1_data[] ={
	{  60,  100,   12, 239, },	// 真ん中一択
	{  160, 191,  192, 255, },	// もどる
 	{TP_HIT_END,0,0,0},
};

static const  RECT_HIT_TBL select_2_1_data[] ={
	{  37,  76,  13, 239, },	// 選択肢上
	{  77, 115,  13, 239, },	// 選択肢下
	{  160, 191,  192, 255, },	// もどる
 	{TP_HIT_END,0,0,0},
};

static const  RECT_HIT_TBL select_3_1_data[] ={
	{  11,   52,   11, 239, },	// 3択上
	{  53,   91,   11, 239, },	// 3択中
	{  92,  132,   11, 239, },	// 3択下
	{  160, 191,  192, 255, },	// もどる
 	{TP_HIT_END,0,0,0},
};

static const  RECT_HIT_TBL select_5_2_data[] ={
	{   0,   31,   11, 239, },	// ５択
	{  32,   63,   11, 239, },	// ５択
	{  64,   95,   11, 239, },	// ５択
	{  96,  127,   11, 239, },	// ５択
	{  128, 159,   11, 239, },	// ５択
	{  160, 191,  192, 255, },	// もどる
	{  162, 191,   12,  35, },	// 左矢印
	{  162, 191,   36,  65, },	// 右矢印
 	{TP_HIT_END,0,0,0},
};

// 通信待機中に「もどる」だけある状態で使う
static const  RECT_HIT_TBL select_1_data[] ={
	{  160, 191,  192, 255, },	// もどる
 	{TP_HIT_END,0,0,0},
};

// タッチ選択テーブル
static const RECT_HIT_TBL *phc_hit_tbl[]={
	yesno_rect_data,	// はい・いいえ
	select_1_1_data,	// 選択肢は１つ、右下に「もどる」
	select_2_1_data,	// 選択肢は２つ、右下に「もどる」
	select_3_1_data,	// 選択肢は３つ、右下に「もどる」
	select_5_2_data,	// 選択肢は５つ、右下に「もどる」
	select_1_data,		// 右下に「もどる」だけ
};

//=============================================================================================
/**
 * @brief	 PHC画面へのタッチ検出
 *
 * @param   index	タッチ定義配列のインデックス
 *
 * @retval  u32		タッチ判定結果
 */
//=============================================================================================
u32 PhcLink_GetTouchTrg( int index )
{
	RECT_HIT_TBL *tbl;

	GF_ASSERT( index < 6 );

	tbl = (RECT_HIT_TBL*)phc_hit_tbl[index];

	return GF_TP_RectHitTrg(tbl);

}


//=============================================================================================
/**
 * @brief	 上画面接続説明画面読み込み
 *
 * @param   wk		PHC画面ワーク
 */
//=============================================================================================
void PhcLink_SetIrcExplainBg( PHCLINK_WORK *wk )
{
	ARCHANDLE *handle = ArchiveDataHandleOpen( ARC_PHCLINK_GRA, HEAPID_PHC_LINK );

	GF_BGL_VisibleSet( GF_BGL_FRAME1_S, VISIBLE_OFF );

	// ----------- サブ画面接続説明画面読み込み -------------------
	ArcUtil_HDL_ScrnSet( handle, NARC_phc_ds_phcds_win03_u_lz_nscr, wk->bgl, GF_BGL_FRAME1_S, 0, 0, 1, HEAPID_PHC_LINK );

	GF_BGL_VisibleSet( GF_BGL_FRAME1_S, VISIBLE_ON );

	// ハンドルクローズ
	ArchiveDataHandleClose( handle );
}

//=============================================================================================
/**
 * @brief	 上画面接続説明画面オンオフ
 *
 * @param   wk		PHC画面ワーク
 * @param   flag	1:ＯＮ　0:ＯＦＦ
 */
//=============================================================================================
void PhcLink_SetIrcExplainVisible( PHCLINK_WORK *wk, int flag )
{
	GF_BGL_VisibleSet( GF_BGL_FRAME1_S, flag );
}


void PhcLink_MakePattiiruStrike( u8* buf, u32 rnd );

#include "..\..\system\patch.dat"


#define PHC_GRA_WIDTH	( 64*2 )	///< PHC画像の横幅定義
//----------------------------------------------------------------------------------
/**
 * @brief	 PHC画像データから2bit値を取得する
 *
 * @param   buf		参照データ
 * @param   x		Ｘ座標(64x48x2前提で作られています）
 * @param   y		Ｙ座標
 *
 * @retval  u8		グレースケール化の結果（0-3）
 */
//----------------------------------------------------------------------------------
static u8 _get_phc_gra_dot( const u8 *buf, int x, int y )
{
	int wy1,wy2, u,t ;
	wy1 = y/8;
	wy2 = y%8;

	// 下位
	u = (buf[ x*2+wy1*PHC_GRA_WIDTH   ]>>wy2)&1;
	// 上位
	t = (buf[ x*2+wy1*PHC_GRA_WIDTH+1 ]>>wy2)&1;

	return ( (t<<1) | u );
}

//----------------------------------------------------------------------------------
/**
 * @brief	PHC画像データに書き込みを行う
 *
 * @param   buf		書き込みバッファ
 * @param   x		X座標
 * @param   y		Y座標
 * @param   dot		書き込むドットデータ(0-3)
 */
//----------------------------------------------------------------------------------
static void _set_phc_gra_dot( u8 *buf, int x, int y, int dot )
{
	int wy1,wy2, u,t ;
	wy1 = y/8;
	wy2 = y%8;
	u = dot&1;
	t = dot&2;

	// 下位
	if(u){		// 指定のビットのみORをかける
		buf[ x*2+wy1*PHC_GRA_WIDTH   ] |= (1<<wy2);
	}else{		// 指定のビットのみ抜いてANDをかける
		buf[ x*2+wy1*PHC_GRA_WIDTH   ] &= (0xff^(1<<wy2));
	}

	// 上位
	if(t){
		buf[ x*2+wy1*PHC_GRA_WIDTH+1 ] |= (1<<wy2);
	}else{
		buf[ x*2+wy1*PHC_GRA_WIDTH+1 ] &= (0xff^(1<<wy2));
	}

}


//----------------------------------------------------------------------------------
/**
 * @brief	PHC画像にパッチールのぶちを書き込む
 *
 * @param   buf			書き込みバッファ（既にパッチールは書き込み済み）
 * @param   mask		パッチールのマスク画像バッファ
 * @param   rnd			個性乱数
 * @param   offsetx		書き込み位置X
 * @param   offsety		書き込み位置Y
 */
//----------------------------------------------------------------------------------
static void _buchi_write( u8 *buf, const u8 *mask, u32 rnd, int offsetx, int offsety)
{
	const	PATCHEEL_STRIKE_DATA	*psd;
	int	i,maskdot;
	u8	setx,sety,cnt;
	int	pos,x,y;


	for(i=0;i<4;i++){
		psd=psd_table[i];
		cnt=0;
		while(psd[cnt].posx!=0xff){
			x = psd[cnt].posx +offsetx  + ((rnd&0x0f)-8);
			y = psd[cnt].posy +offsety  + ((rnd&0xf0)>>4)-8;
			// マスクデータからパッチール画像を取得
			maskdot = _get_phc_gra_dot( mask, x, y );
			// マスクデータが書き込めるドットなら本体に書き込む
			if(maskdot==2){
				_set_phc_gra_dot( buf, x, y, 1 );
			}
			cnt++;
		}
		// 次のぶちの位置を取るために８ビットシフトする
		rnd=rnd>>8;
	}

}

static const char *dot_string[]={" ","-","+","#"};

//============================================================================================
/**
 * @brief		ポケモングラフィックにぶちをつける（PHC専用版）
 *
 *  ※PHCの画像は通常の正面絵80x80と違って64x48。
 *    切り出し設定によると左上(8,14)の場所から切り出されてる
 *
 * @param[in|out] buf			キャラクタデータが展開されたワークへのポインタ(PHCフォーマット）
 * @param[in]	  mask			マスクデータが展開されたワークへのポインタ（PHCフォーマット）
 * @param[in]	  rnd			個性乱数
 */
//============================================================================================
static void MakePattiiruBuchi( u8* buf, const u8* mask, u32 rnd )
{
	int	i;
	u8	setx,sety,cnt;
	int	pos,x,y;
	u32	tmp_rnd;

	tmp_rnd=rnd;


	// ぶち書き込み処理
	_buchi_write( &buf[0],   &mask[0],   rnd,  -8, -14);	// 1枚目
	_buchi_write( &buf[768], &mask[768], rnd, -22, -14);	// 2枚目

	{
		int y,x,dot;
		for(y=0;y<48;y++){
			for(x=0;x<64;x++){
				dot = _get_phc_gra_dot( buf, x , y );
				OS_Printf("%s",dot_string[dot]);
			}
			OS_Printf("\n");
		}
	}


	// この関数じゃダメだった！！！！
	// PHCのならびに対応する必要がある！
#if 0
	//1枚目
	for(i=0;i<4;i++){
		psd=psd_table[i];
		cnt=0;
		while(psd[cnt].posx!=0xff){
			// 書き込む座標の算出(個性乱数の８ビットずつで4箇所の位置を取得する）
			setx=(psd[cnt].posx-8) +((rnd&0x0f)-8);
			sety=(psd[cnt].posy-14)+(((rnd&0xf0)>>4)-8);
			// 書き込むキャラ位置を算出
			pos=setx/2+sety*80;

			// 1バイト内の上位か下位か
			if(setx&1){
				// 書き換えデータのパレットが１から３なら
				if(((buf[pos]&0xf0)>=0x10)&&((buf[pos]&0xf0)<=0x30)){
					// ５を書き込む
					buf[pos]+=0x50;
				}
			}
			else{
				if(((buf[pos]&0x0f)>=0x01)&&((buf[pos]&0x0f)<=0x03)){
					buf[pos]+=0x05;
				}
			}
			cnt++;
		}
		// 次のぶちの位置を取るために８ビットシフトする
		rnd=rnd>>8;
	}

	rnd=tmp_rnd;

	//2枚目
	for(i=0;i<4;i++){
		psd=psd_table[i];
		cnt=0;
		while(psd[cnt].posx!=0xff){
			setx=(psd[cnt].posx-8-14) +((rnd&0x0f)-8);
			sety=(psd[cnt].posy-14)   +(((rnd&0xf0)>>4)-8)+48;
			pos=setx/2+sety*80;
			if(setx&1){
				if(((buf[pos]&0xf0)>=0x10)&&((buf[pos]&0xf0)<=0x30)){
					buf[pos]+=0x50;
				}
			}
			else{
				if(((buf[pos]&0x0f)>=0x01)&&((buf[pos]&0x0f)<=0x03)){
					buf[pos]+=0x05;
				}
			}
			cnt++;
		}
		rnd=rnd>>8;
	}
#endif
}